Bird
0
0

Which SQL clause correctly filters groups where the number of orders exceeds 5?

easy📝 Syntax Q3 of 15
SQL - GROUP BY and HAVING
Which SQL clause correctly filters groups where the number of orders exceeds 5?
AHAVING COUNT(*) > 5
BWHERE COUNT(*) > 5
CGROUP BY COUNT(*) > 5
DORDER BY COUNT(*) > 5
Step-by-Step Solution
Solution:
  1. Step 1: Recognize filtering on aggregate functions

    Filtering groups based on aggregate functions like COUNT requires HAVING.
  2. Step 2: Eliminate incorrect clauses

    WHERE cannot filter on aggregates; GROUP BY and ORDER BY do not filter groups.
  3. Final Answer:

    HAVING COUNT(*) > 5 -> Option A
  4. Quick Check:

    Use HAVING for aggregate filters [OK]
Quick Trick: Use HAVING to filter groups by aggregates like COUNT [OK]
Common Mistakes:
MISTAKES
  • Using WHERE with aggregate functions
  • Misusing GROUP BY as a filter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes