OneBug This week's bugs
Spot the bug SQL
1
-- Customers who never placed a completed order.
2
-- (orders.customer_id is NULL for guest checkouts)
3
SELECT c.customer_id, c.name
4
FROM customers c
5
WHERE c.customer_id NOT IN (
6
    SELECT o.customer_id
7
    FROM orders o
8
    WHERE o.status = 'completed'
9
);

Read the full write-up for this bug (spoilers)