HAVING can filter grouped rows after MAX(amount) has been computed.

highlighted = computed this step

Input table

Use grouped sales rows with one NULL amount.

Sales\text{Sales}
Salesorder_idcategoryamounto1book20o2book35o3pen5o4penNULLo5pen20

Group query

Group by category, take the maximum non-NULL amount, then apply HAVING.

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

Grouped output

Only the group whose maximum amount is above the threshold remains.

max-filtered groups\text{max-filtered groups}
Grouped outputcategorymax_amountbook35