NOT IN pitfall with nulls (safe version)
SQL
Medium
3 views
Problem Description
Find customers who did not place any order. Use NOT EXISTS (safer than NOT IN).
Constraints
Handle NULL safely
Official Solution
SELECT c.customer_id, c.name FROM Customers c WHERE NOT EXISTS (SELECT 1 FROM Orders o WHERE o.customer_id = c.customer_id);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!