AnalystPath

Returns Within 1 Year of Purchase

SQLHardSenior levelAmazon~15 min

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_idcustomer_idproduct_idpurchase_date
returns
return_idpurchase_idreturn_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

Related SQL questions