SQL
5 min read
BEGINNER
Missing values
Quick AnswerNULL represents missing or unknown information, not zero or an empty string. For example, an unreported score differs from a recorded score of zero.
Core idea
NULL represents missing or unknown information, not zero or an empty string. For example, an unreported score differs from a recorded score of zero.
Minimal example
sql
SELECT NULL, 0, '';Expected SQLite rows:
text
NULL | 0 | How it works
The sort_scores fixture from V26 contains scores 10, NULL, 0, NULL. COUNT(*) counts all rows; COUNT(score) counts only non-NULL scores. A client may render NULL as blank, so inspect its display settings.
Practical example
sql
SELECT COUNT(*), COUNT(score) FROM sort_scores;Expected SQLite rows:
text
4 | 2Common mistake and practice
Do not replace an unknown score with zero unless the business rule explicitly requires it. Predict the number of unreported scores by subtracting the two counts.