Chapter 8 · Window Functions
17. Dense Rank Customers by Total Spending
Hard40 XPE-Commerce
Rank all customers by their total spending using DENSE_RANK (no gaps in rankings). Return customer name, total spent, and their spending rank. Show only the top 10 spenders.
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.