Chapter 9 · Interview Level
13. Each Customer's Most Recent Order Amount
Medium20 XPE-Commerce
For each customer, find the total_amount of their most recent order. Use a correlated subquery to match each customer to their latest order. Return customer_id, order_date, and total_amount.
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.