1
SQLIntermediate#queries
WHERE filters individual rows before grouping and cannot use aggregate functions. HAVING filters groups produced by GROUP BY and can use aggregates.
SELECT dept_id, COUNT(*) AS total FROM employees WHERE active = 1 -- row filter GROUP BY dept_id HAVING COUNT(*) > 5; -- group filter