SQL aggregates handle NULL differently by function.
highlighted = computed this step
Aggregates skip NULL differently
Aggregate functions have sharp edges around NULL. COUNT star counts every row, while column aggregates skip missing values. Note: every number below is read from the compiled aggregate result.
aggregate sharp edges
Exact aggregate result
COUNT star is 5, COUNT grade is 4, and COUNT DISTINCT grade is 3. SUM, MIN, and MAX are 330, 70, and 90.
count star=5,sum=330
SQL bag/multiset + three-valued NULL logic, deterministic but surprising; tiny finite tables; no engine/perf claims. Set algebra is Book 1.
Summary
COUNT star counts rows, while COUNT column, SUM, MIN, and MAX skip NULL values. Note: bag and NULL semantics are here; set algebra was Book One.