Problem Statement
Which clause filters rows before aggregation and affects which rows are grouped?
Explanation
WHERE applies to raw rows, before grouping. It reduces input early and improves performance when selective.
Use HAVING after GROUP BY when you need to filter on aggregate results, like COUNT or SUM.
Code Solution
SolutionRead Only
SELECT department_id, COUNT(*) FROM employees WHERE active = 1 GROUP BY department_id;
