Bird
0
0

Why does SUM(amount) OVER () return the same value for every row in the result set?

hard📝 Conceptual Q10 of 15
SQL - Advanced Window Functions
Why does SUM(amount) OVER () return the same value for every row in the result set?
ABecause it sums only the current row's amount
BBecause it calculates the total sum over all rows without partitioning
CBecause it groups rows by amount before summing
DBecause it orders rows and sums cumulatively
Step-by-Step Solution
Solution:
  1. Step 1: Understand window function without partition

    Without PARTITION BY, the window function considers all rows as one group.
  2. Step 2: Explain why sum is same for all rows

    SUM(amount) OVER () sums all rows and returns that total for each row.
  3. Final Answer:

    It calculates the total sum over all rows without partitioning -> Option B
  4. Quick Check:

    Empty OVER() means full table aggregation [OK]
Quick Trick: Empty OVER() means sum over entire table [OK]
Common Mistakes:
  • Thinking it sums only current row
  • Confusing with cumulative sum
  • Assuming grouping by amount

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes