Bird
0
0

What does the COUNT(*) OVER() window function do in PostgreSQL?

easy📝 Conceptual Q11 of 15
PostgreSQL - Window Functions in PostgreSQL
What does the COUNT(*) OVER() window function do in PostgreSQL?
ACounts all rows in the result set without grouping them.
BCounts only distinct rows in the table.
CCounts rows and groups them by a specified column.
DCounts rows but returns only one aggregated result.
Step-by-Step Solution
Solution:
  1. Step 1: Understand COUNT(*) OVER() usage

    The function counts all rows in the query result but does not group or collapse rows.
  2. Step 2: Difference from GROUP BY

    Unlike GROUP BY, it keeps all rows visible and adds the count as a column.
  3. Final Answer:

    Counts all rows in the result set without grouping them. -> Option A
  4. Quick Check:

    COUNT(*) OVER() counts all rows [OK]
Quick Trick: Window COUNT(*) counts all rows without grouping [OK]
Common Mistakes:
  • Confusing window COUNT with GROUP BY count
  • Thinking it returns a single aggregated row
  • Assuming it counts distinct values only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes