HAVING filters grouped rows after COUNT(*) has been computed.
highlighted = computed this step
Input table
Start with the same sales rows used for grouping.
Group query
Group by category, count every row, then apply HAVING to the count.
GROUP BY category HAVING COUNT(*)
Grouped output
Only the category whose count is above the threshold remains.
groups after HAVING