Customers who never ordered
MediumNULLs and anti-joinsE-commerce
The problem
Find customers who have never placed any order (of any status).
Return name and city. Some cities are NULL — keep those customers.
Learn this in the course: Joins and NULLs (video and notes)
Tables · Online shop
Click a table or column name to insert it into your query.
- INTEGER · primary key
- TEXT
- TEXT · can be NULL
- DATE
Sample rows (10 total)
| customer_id | name | city | signup_date |
|---|---|---|---|
| 1 | Aarav Mehta | Mumbai | 2025-01-10 |
| 2 | Diya Nair | Bengaluru | 2025-01-18 |
| 3 | Kabir Singh | Delhi | 2025-02-02 |
| 4 | Meera Iyer | Chennai | 2025-02-14 |
| 5 | Rohan Das | Kolkata | 2025-03-01 |
- INTEGER · primary key
- INTEGER · → customers
- DATE
- TEXT · delivered | cancelled | returned | pending
- INTEGER · rupees
Sample rows (20 total)
| order_id | customer_id | order_date | status | amount |
|---|---|---|---|---|
| 1 | 1 | 2025-05-01 | delivered | 1200 |
| 2 | 1 | 2025-05-15 | delivered | 800 |
| 3 | 1 | 2025-06-02 | cancelled | 500 |
| 4 | 2 | 2025-05-03 | delivered | 2500 |
| 5 | 2 | 2025-05-20 | delivered | 450 |
Ctrl/⌘ + Enter runs the query. Table and column names are suggested as you type. Press Esc then Tab to leave the editor with the keyboard.
Expected output (3 rows)
| name | city |
|---|---|
| Tara Joshi | Pune |
| Sana Khan | NULL |
| Neel Patel | Ahmedabad |
Row order doesn’t matter for this question. Numbers are compared with a tiny tolerance; text must match exactly.
Stuck?
Stored on this device only. Your latest query and “solved” status are remembered in this browser only. They don’t sync between devices, and clearing your browser data removes them.