SUM(amount) adds non-NULL amounts inside each category group.

highlighted = computed this step

Input table

Use the same sales rows with one NULL amount.

Sales\text{Sales}
Salesorder_idcategoryamounto1book20o2book35o3pen5o4penNULLo5pen20

Group query

Group by category and add the non-NULL amounts.

GROUP BY category, SUM(amount)\text{GROUP BY category, SUM(amount)}
GROUP BY category sumgroup_byarity 2 rows 2Salesarity 3 rows 5

Grouped output

The NULL amount is skipped by SUM.

sums by category\text{sums by category}
Grouped outputcategorytotal_amountbook55pen25