Bird
0
0

What will be the output of this query?

medium📝 query result Q5 of 15
SQL - GROUP BY and HAVING
What will be the output of this query?
SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 10;
ADepartments with more than 10 employees
BAll departments regardless of employee count
CEmployees with department count over 10
DSyntax error due to missing WHERE clause
Step-by-Step Solution
Solution:
  1. Step 1: GROUP BY groups employees by department

    Each department forms a group of employees.
  2. Step 2: HAVING filters groups with COUNT(*) > 10

    Only departments with more than 10 employees are included in output.
  3. Final Answer:

    Departments with more than 10 employees -> Option A
  4. Quick Check:

    HAVING filters groups by aggregate count [OK]
Quick Trick: HAVING filters groups by aggregate conditions [OK]
Common Mistakes:
MISTAKES
  • Thinking HAVING filters rows
  • Expecting all departments without filter
  • Assuming WHERE is mandatory with HAVING

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes