Question DB-SQL-0001
EasyWhat does this query return?
SELECT dept, COUNT(*)
FROM employees
GROUP BY dept
HAVING COUNT(*) > 2;
- A.
All departments with their employee count
- B.
Departments that have more than 2 employees
- C.
Show answer and explanation
Answer: B
GROUP BY makes one group per department, and HAVING filters those groups after counting, keeping only departments with more than 2 employees. HAVING does not need a WHERE clause.