HAVING Filter
Predict Output Medium
Question
What does this SQL produce?
Code
-- employees: IT(5), HR(2), Sales(8)
SELECT dept, COUNT(*) FROM employees
GROUP BY dept HAVING COUNT(*) > 3;
Hint
HAVING filters groups where count exceeds 3.
Explanation
GROUP BY creates 3 groups. HAVING COUNT(*) > 3 filters groups with more than 3 employees. IT (5) and Sales (8) pass; HR (2) is filtered out. Result: IT: 5, Sales: 8.
Related Resources
Related Lessons
- GROUP BY
Learn GROUP BY.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.