SQL
5 min read
BEGINNER
NULL propagation
Quick AnswerOrdinary arithmetic with NULL produces NULL. A missing input is not automatically converted to zero.
Core idea
Ordinary arithmetic with NULL produces NULL. A missing input is not automatically converted to zero.
Minimal example
sql
SELECT NULL + 5, NULL * 0, 0 + 5;Expected SQLite rows:
text
NULL | NULL | 5How it works
Adding five to an unknown score still gives an unknown result. Not every function propagates NULL: COUNT(score) ignores NULL inputs, and COALESCE selects the first non-NULL value (covered next chapter). Use the latter only with a meaningful default.
Practical example
sql
SELECT id, score + 5 FROM sort_scores ORDER BY id;Expected SQLite rows:
text
1 | 152 | NULL3 | 54 | NULLCommon mistake and practice
Predict the adjusted scores without inventing missing values. Compare with COALESCE(score, 0) + 5 only if zero is an approved default.