Bird
0
0

Which of the following best describes how the FILTER clause differs from a WHERE clause in aggregation?

easy📝 Conceptual Q2 of 15
PostgreSQL - Aggregate Functions and GROUP BY
Which of the following best describes how the FILTER clause differs from a WHERE clause in aggregation?
AFILTER filters rows before grouping, WHERE filters after grouping
BFILTER is used only for sorting results
CFILTER and WHERE do the same thing in aggregation
DFILTER applies conditions after grouping, WHERE applies before grouping
Step-by-Step Solution
Solution:
  1. Step 1: Understand WHERE and FILTER timing

    WHERE filters rows before grouping happens, so it affects which rows enter the aggregation. FILTER applies conditions inside aggregate functions after grouping.
  2. Step 2: Eliminate incorrect options

    FILTER does not filter before grouping, and it is not for sorting. WHERE and FILTER are not the same.
  3. Final Answer:

    FILTER applies conditions after grouping, WHERE applies before grouping -> Option D
  4. Quick Check:

    FILTER vs WHERE timing = FILTER after grouping [OK]
Quick Trick: WHERE filters rows before grouping; FILTER filters inside aggregates [OK]
Common Mistakes:
  • Thinking FILTER filters rows before grouping
  • Confusing FILTER with sorting
  • Assuming WHERE and FILTER are interchangeable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes