GROUP BY category partitions rows, then COUNT(*) counts every row per group.
highlighted = computed this step
Input table
Start with sales rows grouped by category.
Group query
Group by category and count every row in each group.
GROUP BY category, COUNT(*)
Grouped output
The count includes the row whose amount is NULL.
row counts by category