Next-Day Order Confirmations
Problem
A retailer stores orders in orders(order_ref, customer_id, placed_at) and follow-up phone calls in callbacks(callback_ref, order_ref, outcome, called_at). Find the customer_id of every customer whose order was confirmed exactly one calendar day after it was placed: the matching callback must have outcome 'Confirmed' and its call date must be exactly one day after the order's placement date. Order the result by customer_id ascending.
Tables
Example rows — the live problem includes the full dataset.
| order_ref | customer_id | placed_at |
|---|---|---|
| 125 | 6312 | 2024-06-14 09:30:00 |
| 433 | 6477 | 2024-07-09 08:15:00 |
| 234 | 6190 | 2024-08-20 10:00:00 |
| callback_ref | order_ref | outcome | called_at |
|---|---|---|---|
| 1 | 125 | Confirmed | 2024-06-15 08:30:00 |
| 2 | 433 | Declined | 2024-07-10 10:45:00 |
| 4 | 234 | Confirmed | 2024-08-21 09:30:00 |
Expected output
Your answer should return 2 rows with the columns customer_id.
Starter code (SQL)
SELECT *
FROM orders;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