Window frame · RANGE vs ROWS

Why the first row's running total is 300

Why the first row's running total is 300 Three rows: 2026-01-01 100, 2026-01-01 200, 2026-01-02 300. With the default RANGE frame, row 1's frame covers both peer rows on the same date, so the sum is 300. With ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, row 1's frame is just itself, so the sum is 100. DEFAULT · RANGE sum(tien) OVER (ORDER BY ngay) sum = 300for row 1 1 2026-01-01 100 2 2026-01-01 200 3 2026-01-02 300 ngay tien Both 2026-01-01 rows are peers, so RANGE puts both in row 1's frame. EXPLICIT · ROWS sum(tien) OVER (ORDER BY ngay ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum = 100for row 1 1 2026-01-01 100 2 2026-01-01 200 3 2026-01-02 300 ngay tien ROWS counts physical positions, so row 1's frame is just itself. LEGEND Row 1's window frame Current row © tiennhm