You use the HAVING clause to filter groups of rows.
GROUP BY can be used without HAVING.
But HAVING must be used in conjunction with GROUP BY.
You place the HAVING clause after your GROUP BY clause:
SELECT ...
FROM ...
WHERE
GROUP BY ...
HAVING ...
ORDER BY ...;