GROUP BY forms groups and treats NULL as its own group.

highlighted = computed this step

GROUP BY forms groups

GROUP BY partitions rows by the grouping value and computes aggregates per group. NULL forms its own group instead of disappearing. Note: the result table shows the groups.

group by\text{group by}

Grouping grades

The recomputed group count is 4. Note: the missing grade appears as its own rendered group.

groups=4\text{groups}=4

SQL bag/multiset + three-valued NULL logic, deterministic but surprising; tiny finite tables; no engine/perf claims. Set algebra is Book 1.

GROUP BY grade group_by arity 2 rows 4 Grades arity 3 rows 5
group_by grade n 70 1 80 1 90 2 NULL 1

Summary

GROUP BY treats NULL as a grouping value for grouping purposes. Note: bag and NULL behavior are here; set algebra was Book One.

group summary\text{group summary}