📞 0339-0387701 (WhatsApp) Contact

« Back to Database & Data Handling (NCCIA)

Which statement shows departments with more than 10 employees?

A. SELECT Department, COUNT(*) FROM Employees WHERE COUNT(*) > 10 GROUP BY Department
B. SELECT Department FROM Employees GROUP BY Department WHERE COUNT(*) > 10
C. SELECT Department, COUNT(*) FROM Employees GROUP BY Department ORDER BY COUNT(*) > 10
D. SELECT Department, COUNT(*) FROM Employees GROUP BY Department HAVING COUNT(*) > 10 ✅

Correct Answer: D. SELECT Department, COUNT(*) FROM Employees GROUP BY Department HAVING COUNT(*) > 10

Explanation

Aggregate conditions on groups must use HAVING, because WHERE cannot test COUNT(*) before grouping.