Bird
0
0

Which of the following is the correct syntax to filter groups with HAVING?

easy📝 Syntax Q12 of 15
SQL - GROUP BY and HAVING

Which of the following is the correct syntax to filter groups with HAVING?

SELECT department, COUNT(*) FROM employees GROUP BY department _______ COUNT(*) > 5;
AGROUP BY
BWHERE
CFILTER
DHAVING
Step-by-Step Solution
Solution:
  1. Step 1: Identify filtering clause after grouping

    After GROUP BY, filtering groups requires HAVING, not WHERE.
  2. Step 2: Confirm correct clause usage

    HAVING COUNT(*) > 5 filters groups with more than 5 employees.
  3. Final Answer:

    HAVING -> Option D
  4. Quick Check:

    Use HAVING after GROUP BY [OK]
Quick Trick: Use HAVING to filter groups, not WHERE [OK]
Common Mistakes:
MISTAKES
  • Using WHERE instead of HAVING after GROUP BY
  • Placing HAVING before GROUP BY
  • Using FILTER keyword which is invalid here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes