IntermediateJoins25 points
Customers who never ordered
The CRM team wants to send a welcome-back discount to customers who signed up but never placed any order (cancelled orders count as orders).
Task: return the name and city of these customers, sorted by name.
The data you can query
Each table is shown with its column types and the first rows, so you can see exactly what the data looks like.
customers14 rows
| id INTEGER | name TEXT | city TEXT | signup_date TEXT |
|---|---|---|---|
| 1 | Ayesha Khan | Lahore | 2025-11-03 |
| 2 | Bilal Ahmed | Karachi | 2025-11-12 |
| 3 | Hina Malik | Islamabad | 2025-12-01 |
| 4 | Usman Tariq | Rawalpindi | 2025-12-15 |
| 5 | Sana Iqbal | Lahore | 2026-01-04 |
| 6 | Omar Farooq | Faisalabad | 2026-01-20 |
Showing the first 6 of 14 rows.
order_items80 rows
| id INTEGER | order_id INTEGER | product_id INTEGER | quantity INTEGER |
|---|---|---|---|
| 1 | 1 | 1 | 2 |
| 2 | 1 | 2 | 4 |
| 3 | 2 | 6 | 1 |
| 4 | 2 | 2 | 4 |
| 5 | 2 | 10 | 4 |
| 6 | 3 | 9 | 1 |
Showing the first 6 of 80 rows.
orders40 rows
| id INTEGER | customer_id INTEGER | order_date TEXT | status TEXT |
|---|---|---|---|
| 1 | 3 | 2026-01-16 | Delivered |
| 2 | 11 | 2026-06-14 | Delivered |
| 3 | 7 | 2026-02-15 | Delivered |
| 4 | 10 | 2026-06-19 | Delivered |
| 5 | 5 | 2026-01-06 | Delivered |
| 6 | 9 | 2026-03-06 | Delivered |
Showing the first 6 of 40 rows.
products10 rows
| id INTEGER | name TEXT | category TEXT | price REAL |
|---|---|---|---|
| 1 | Wireless Mouse | Electronics | 1850 |
| 2 | USB Cable | Electronics | 450 |
| 3 | Bluetooth Speaker | Electronics | 4200 |
| 4 | Notebook A4 | Stationery | 220 |
| 5 | Gel Pen Pack | Stationery | 180 |
| 6 | Desk Organizer | Stationery | 950 |
Showing the first 6 of 10 rows.
Your query runs on SQLite. Write a single SELECT; use LIMIT instead of TOP.
Need a hint?
A LEFT JOIN keeps customers with no match. Rows with no order have NULL in the orders columns.
SQL · SQLite
25 pts
Loading editor...
Log in or create a free account to run your code, submit and earn points.
Run your code to see the output here. Ctrl + Enter also runs it.
