Bird
0
0

What does the SUM() OVER() window function calculate in PostgreSQL?

easy📝 Conceptual Q1 of 15
PostgreSQL - Window Functions in PostgreSQL
What does the SUM() OVER() window function calculate in PostgreSQL?
AThe count of non-null values in a column
BA running total of values over a specified window
CThe average of values in the entire table
DThe total sum of all rows in the table ignoring any partition
Step-by-Step Solution
Solution:
  1. Step 1: Understand the SUM() function with OVER()

    The SUM() function when used with OVER() calculates a running total or sum over a defined window of rows.
  2. Step 2: Differentiate from aggregate SUM()

    Unlike aggregate SUM(), the window function does not collapse rows but returns a sum for each row based on the window.
  3. Final Answer:

    A running total of values over a specified window -> Option B
  4. Quick Check:

    SUM() OVER() = Running Total [OK]
Quick Trick: SUM() OVER() gives running totals, not just total sum [OK]
Common Mistakes:
  • Confusing window SUM() with aggregate SUM()
  • Thinking it returns a single total value
  • Ignoring the window frame concept

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes