HAVING can filter on an aggregate alias such as SUM(amount).

highlighted = computed this step

Input table

Use grouped sales rows with one NULL amount.

Sales\text{Sales}
Salesorder_idcategoryamounto1book20o2book35o3pen5o4penNULLo5pen20

Group query

Group by category, sum non-NULL amounts, then apply HAVING to the sum.

GROUP BY category HAVING SUM(amount)\text{GROUP BY category HAVING SUM(amount)}
GROUP BY category HAVING sum thresholdgroup by havingarity 2 rows 1Salesarity 3 rows 5

Grouped output

Only the group whose total is above the threshold remains.

sum-filtered groups\text{sum-filtered groups}
Grouped outputcategorytotal_amountbook55