Above the Customer Average
Part of the Connected Data section of Coddy's PostgreSQL journey. Lesson 10 of 25.
Challenge
MediumUse a CTE to calculate total order amount per customer, then return customer_id and total for customers whose total exceeds the average of those customer totals. Include ordering customers only and order by customer_id.
The input tables are shown in the test panel. Each run starts from fresh data. Return the named columns in the stated order; do not hard-code the displayed rows.
Try it yourself
-- Write your SQL here.
All lessons in Connected Data
2Queries in Stages
Scalar SubqueriesCheck ExistenceName a Query with WITHChain CTEsAbove the Customer AveragePractice on your own: PostgreSQL playground