NULL Is Not Zero, Blank, or False
Use IS NULL, IS NOT NULL, and COUNT behavior correctly in basic filters and aggregates.
NULL is a state, not a value you compare with equals. That one distinction prevents a large class of silent SQL mistakes. Filtering missing values Use IS NULL when you want missing values and IS NOT NULL when you want present values. Equality and inequality comparisons are for known values. In WHERE, unknown is not kept. Counting with NULLs COUNT(*) answers: how many rows are in this group? COUNT(column) answers: how many rows have a non-null value in this column? COUNT(DISTINCT column) answers: how many different known values appear? Those are three different business questions. Outer-join NULLs After a LEFT…
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in