Bird
0
0

Why is the HAVING clause necessary when filtering grouped data in PostgreSQL?

hard📝 Conceptual Q10 of 15
PostgreSQL - Aggregate Functions and GROUP BY
Why is the HAVING clause necessary when filtering grouped data in PostgreSQL?
ABecause WHERE cannot filter aggregated results
BBecause HAVING sorts grouped data
CBecause HAVING joins tables
DBecause WHERE filters groups after aggregation
Step-by-Step Solution
Solution:
  1. Step 1: Understand WHERE limitations

    WHERE filters rows before aggregation, so it cannot filter aggregated results.
  2. Step 2: Role of HAVING

    HAVING filters groups after aggregation, allowing conditions on aggregated values.
  3. Final Answer:

    Because WHERE cannot filter aggregated results -> Option A
  4. Quick Check:

    HAVING filters aggregates, WHERE cannot = C [OK]
Quick Trick: HAVING filters aggregates; WHERE filters rows before grouping [OK]
Common Mistakes:
  • Thinking WHERE can filter aggregates
  • Confusing HAVING with sorting or joining
  • Misunderstanding clause purposes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes