CS FundamentalsVery hardProduct-company placement

Pay(d, amt) has rows (1, 10), (2, 20), (2, 30), (3, 40). For the row (2, 20), what value does SUM(amt) OVER (ORDER BY d) give?

  1. A. 30
  2. B. 60
  3. C. 20
  4. D. 100

Correct answer: B. 60

With ORDER BY and no frame clause the default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which includes all peers with the same d. Both d = 2 rows get 10 + 20 + 30 = 60; 30 is what a ROWS frame would give.

More DBMS and SQL questions

Exams that ask this topic