← SQL Deep Dive
9 / 25
Lesson 9 — IS NULL and COUNT(column)
NULL is not equal to anything
NULL means "unknown", so x = NULL is never true — not even when x is NULL. To test for missing values use IS NULL or IS NOT NULL. Aggregates differ too: COUNT(*) counts all rows, but COUNT(column) counts only rows where that column is not NULL.
SELECT COUNT(*) FROM orders WHERE shipped_at IS NULL
Why it matters: WHERE phone = NULL silently returns nothing — a classic bug that makes reports say "0 users without a phone".
Want it another way?
Task
Fix the broken query: use IS NULL instead of = NULL. Expected: the = NULL count is 0, the IS NULL count is 2.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.