Bird
0
0

What is the main purpose of the HAVING clause in a PostgreSQL query?

easy📝 Conceptual Q11 of 15
PostgreSQL - Aggregate Functions and GROUP BY
What is the main purpose of the HAVING clause in a PostgreSQL query?
ATo join two tables
BTo filter rows before grouping
CTo sort the result set
DTo filter groups after aggregation
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of HAVING

    The HAVING clause is used to filter groups created by GROUP BY based on aggregate conditions.
  2. Step 2: Differentiate HAVING from WHERE

    WHERE filters rows before grouping, HAVING filters groups after aggregation.
  3. Final Answer:

    To filter groups after aggregation -> Option D
  4. Quick Check:

    HAVING filters groups = D [OK]
Quick Trick: Remember HAVING filters groups, WHERE filters rows [OK]
Common Mistakes:
  • Confusing HAVING with WHERE clause
  • Thinking HAVING sorts data
  • Using HAVING without GROUP BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes