Bird
0
0

What does the PARTITION BY clause do in a window function in PostgreSQL?

easy📝 Conceptual Q11 of 15
PostgreSQL - Window Functions in PostgreSQL
What does the PARTITION BY clause do in a window function in PostgreSQL?
AIt filters rows before the window function is applied.
BIt divides the rows into groups to perform calculations within each group.
CIt sorts the entire table before applying the window function.
DIt removes duplicate rows from the result set.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of PARTITION BY

    PARTITION BY groups rows so window functions calculate results within each group separately.
  2. Step 2: Differentiate from filtering and sorting

    Filtering removes rows, sorting orders rows, but PARTITION BY only groups rows without removing or sorting them globally.
  3. Final Answer:

    It divides the rows into groups to perform calculations within each group. -> Option B
  4. Quick Check:

    PARTITION BY = grouping rows for window functions [OK]
Quick Trick: Remember: PARTITION BY groups rows, it does not filter or sort [OK]
Common Mistakes:
  • Confusing PARTITION BY with WHERE filtering
  • Thinking PARTITION BY sorts all rows
  • Assuming PARTITION BY removes duplicates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes