GROUP BY keeps NULL category values together as their own bucket.

highlighted = computed this step

Input table

Start with sales rows where two category cells are NULL.

Sales with NULL category\text{Sales with NULL category}
Salesorder_idcategoryamounts1book20s2NULL15s3pen5s4NULL10

Group query

Group by category and count every row in each key bucket.

GROUP BY category with NULL\text{GROUP BY category with NULL}
GROUP BY category with NULL bucketgroup_byarity 2 rows 3Salesarity 3 rows 4

Grouped output

Rows with NULL category form one NULL bucket.

NULL category bucket\text{NULL category bucket}
Grouped outputcategoryorder_countbook1pen1NULL2