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(s) with the highest number of points, using the first CTE.
Update product prices, increasing by $0.05 for the grocery stores with the highest number of points.
In first WITH
use the SUM
aggregate function to select the sum of all points gathered by each grocery store.
In the second WITH
clause, select records with only those grocery stores which obtain the highest sum of points. Use the MAX
aggregate function with the value obtained from the first CTE.
In the UPDATE
statement, use the IN
clause with subquery, selecting the IDs of grocery stores from the second CTE.