GROUP BY Count
Predict Output Easy
Question
What does this SQL produce?
Code
-- employees: dept="IT" (3 people), dept="HR" (2 people)
SELECT dept, COUNT(*) FROM employees GROUP BY dept;
Hint
GROUP BY groups by dept, COUNT gives per-group count.
Explanation
GROUP BY dept creates two groups: IT and HR. COUNT(*) returns the number of employees in each group: IT has 3, HR has 2. Result: 2 rows (IT: 3, HR: 2).
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.