Chapter 6 · Subqueries
05. High-Spending Customers
Medium20 XPE-Commerce
Identify VIP customers whose total spending exceeds the average customer's total spending. Return the customer's full name and their total spent, sorted by total spent (highest first). Use a subquery to compute the average total spending per customer.
Tables
- PKidINT
- first_nameTEXT
- last_nameTEXT
- emailTEXT
- phoneTEXT
- cityTEXT
- stateTEXT
- countryTEXT
- created_atTIMESTAMP
- 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.