NULL means 'unknown', and it behaves unlike any value: it isn't equal to anything, not even itself. Mishandled NULLs silently distort counts, averages, and joins — so every analyst needs these patterns.
Key Points
- Test with IS NULL / IS NOT NULL — never col = NULL
- Replace for display: COALESCE(phone, 'Not provided') or IFNULL(x, 0)
- COUNT(col) skips NULLs; COUNT(*) doesn't — pick deliberately
- AVG ignores NULLs; decide whether that's what your metric intends
- NULLs in join keys never match — rows silently disappear
- NULLIF(a, b) returns NULL when a=b, handy for avoiding divide-by-zero
.png)