Skip to content
Justice Tech School

Counting Groups with NULL

NULL values form their own group in GROUP BY.

Example
SELECT score IS NULL AS missing, COUNT(*) AS n FROM students GROUP BY missing;

Result

missing | n
0       | 7
1       | 1

Exercise

Missing flag.

score IS  AS missing

Quiz Test

How does GROUP BY treat NULL?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.