Chapter 6 · Subqueries
12. Orders Exceeding Customer's Own Average
Medium20 XPE-Commerce
Find all orders where the total_amount exceeds the placing customer's average order total. Return order id, customer_id, total_amount, and the customer's average (rounded to 2 decimals). Sort by customer_id, then order id.
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.