COUNT(amount) counts only non-NULL amount values inside each category group.

highlighted = computed this step

Input table

Start with sales rows where one pen amount is NULL.

Sales\text{Sales}
Salesorder_idcategoryamounto1book20o2book35o3pen5o4penNULLo5pen20

Group query

Group by category and count only non-NULL amount cells.

GROUP BY category, COUNT(amount)\text{GROUP BY category, COUNT(amount)}
GROUP BY category count non-NULL amountgroup_byarity 2 rows 2Salesarity 3 rows 5

Grouped output

The pen group has three rows, but only two non-NULL amounts.

non-NULL amount counts\text{non-NULL amount counts}
Grouped outputcategoryamount_countbook2pen2