Chapter 6 · Subqueries
07. Orders with the Most Line Items
Medium20 XPE-Commerce
Find the orders that have the most distinct products (line items). Return the order_id, the count of distinct products, and the order total_amount. Show only orders whose product count equals the maximum across all orders.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- order_dateTEXT
- statusTEXT
- total_amountREAL
- PKidINT
- FKorder_id→ orders.idINT
- FKproduct_id→ products.idINT
- quantityINT
- unit_priceREAL
- discountREAL
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.