MAX(amount) keeps the largest non-NULL amount value 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 take the largest non-NULL amount.

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

Grouped output

The NULL amount is skipped, so the pen maximum is the largest known amount.

maximum amounts by category\text{maximum amounts by category}
Grouped outputcategorymax_amountbook35pen20