Bird
0
0

What does the FILTER clause do in a PostgreSQL aggregate function?

easy📝 Conceptual Q11 of 15
PostgreSQL - Aggregate Functions and GROUP BY
What does the FILTER clause do in a PostgreSQL aggregate function?
AIt filters the entire table before aggregation starts.
BIt applies a condition to include only certain rows in the aggregation.
CIt changes the grouping columns in the query.
DIt sorts the results after aggregation.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of FILTER in aggregation

    The FILTER clause allows you to specify a condition inside an aggregate function to include only rows that meet that condition.
  2. Step 2: Compare with other options

    FILTER does not filter the whole table before aggregation, nor does it change grouping or sort results. It only limits rows counted or summed inside the aggregate.
  3. Final Answer:

    It applies a condition to include only certain rows in the aggregation. -> Option B
  4. Quick Check:

    FILTER = condition inside aggregate [OK]
Quick Trick: FILTER applies conditions inside aggregates, not on whole table [OK]
Common Mistakes:
  • Thinking FILTER filters rows before aggregation
  • Confusing FILTER with WHERE clause
  • Assuming FILTER changes GROUP BY columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes