D8LooPFocus modeCODE WORKSPACE
Return c.customer_id, c.country, and c.created_at for customers who have no rows in orders. Order by customer_id.
LEFT JOIN orders, then WHERE o.order_id IS NULL keeps customers with no match.
Sample input
| customer_id | country | created_at |
|---|---|---|
| 1 | US | 2025-11-02 |
| 2 | null | 2025-12-10 |
| 3 | GB | 2026-01-05 |
| 4 | IN | 2026-01-09 |
| 5 | US | 2025-10-01 |
| 6 | GB | 2026-01-15 |
| order_id | buyer_id |
|---|---|
| 1001 | 1 |
| 1002 | 3 |
| 1003 | 4 |
| 1005 | 2 |
| 1006 | 6 |
Expected output
| customer_id | country | created_at |
|---|---|---|
| 5 | US | 2025-10-01 |
Constraints
LEFT JOIN customers to orders on orders.buyer_id = customers.customer_id, then keep only rows where orders.order_id IS NULL (the anti-join).
Expected skills
LEFT JOIN to preserve all customers and the anti-join pattern (IS NULL on the right key) to keep only unmatched rows.
Run the SQL query to inspect preview rows.