Returns Within 1 Year of Purchase
Problem
**[Asked at Amazon]**
Find all `customer_id` and `product_id` pairs where a return was made within
**365 days** of purchase. Order by customer then product.
Tables
Example rows — the live problem includes the full dataset.
purchases
| purchase_id | customer_id | product_id | purchase_date |
|---|
returns
| return_id | purchase_id | return_date |
|---|
Expected output
Your answer should return 1 row with the columns customer_id, product_id.
Starter code (SQL)
SELECT *
FROM purchases;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock