Chapter 4 · Aggregations
52. Top 5 Customers by Total Spend
Medium20 XPE-Commerce
The VIP program manager wants the top 5 customers ranked by total spending. Return customer_id and the sum of total_amount across all their orders. Only include customers with at least 2 orders. Sort by total spend descending and limit to 5.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- order_dateTEXT
- statusTEXT
- total_amountREAL
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.