Chapter 8 · Window Functions
24. Rank Customers by Order Value with RANK and DENSE_RANK
Hard40 XPE-Commerce
For each order, rank customers by total_amount using both RANK() and DENSE_RANK(). Return customer_id, order_date, total_amount, the RANK value, and the DENSE_RANK value. Order by total_amount descending.
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.