Question 1
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.
Employees who belong to more than 2 departments
- D.
An error because HAVING needs WHERE
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.