Chapter 9 · Interview Level
06. Combine Cancelled and Returned Orders
Easy10 XPE-Commerce
The loss prevention team needs a combined list of problematic orders. Write a query that returns all cancelled orders and all returned orders as a single result set. Include the order id, customer_id, order_date, status, and total_amount. Use UNION ALL to preserve duplicates. Sort by order_date, newest first.
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.