Code a storewide (i.e. all-product) price change for the store with the most customer satisfaction points.
In the first CTE, select the sums of customer satisfaction points for all orders for each grocery store. In the second CTE, select the ID of the grocery store with the highest number of points, using the first CTE.
Update the product prices, increasing them by $0.05 only for the grocery store with the highest number of satisfaction points.
In the first WITH
, use the SUM
aggregate function to select the sum of all points given to each grocery store.
In the second WITH
clause, select only those records for the grocery stores with the highest sum of points. Use the MAX
aggregate function with the value obtained from the first CTE.
In the UPDATE
statement, use an IN
clause with a subquery that selects the IDs of grocery stores from the second CTE.