Interview › Anti-join
SQL interview: customers with no orders (LEFT JOIN IS NULL)
“Employees without orders” is the same as “customers who never bought.”
Prompt. Return customers who have no row in Orders.
Hint: LEFT JOIN Orders, WHERE o.customer_id IS NULL
SELECT c.customer_id, c.email
FROM Customers c
LEFT JOIN Orders o ON o.customer_id = c.customer_id
WHERE o.customer_id IS NULL;
NOT EXISTS is often cleaner. NOT IN (subquery) dies if the subquery returns NULL.
Then write it on a ticket
Monday is free. A colleague asks, you type, we mark it.
Clock in free