Reviewed by Aditya Kumar · Last reviewed 2026-03-24
SELECT date, amount, SUM(amount) OVER (ORDER BY date) AS running_total FROM sales. **Default frame**: RANGE UNBOUNDED PRECEDING = cumulative. **Partitioned**: SUM(amount) OVER (PARTITION BY region ORDER BY date). **Determinism**: If date has duplicates, RANGE treats peers...
SELECT date, amount, SUM(amount) OVER (ORDER BY date) AS running_total FROM sales. Default frame: RANGE UNBOUNDED PRECEDING = cumulative. Partitioned: SUM(amount) OVER (PARTITION BY region ORDER BY date). Determinism: If date has duplicates, RANGE treats peers together; use ROWS for row-by-row. Index: date for sort.
Red Flag: ORDER BY non-unique column without ROWS/RANGE—undefined peer order. Pro-Move: 'We used ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW for deterministic running total when dates had ties.'
According to DataEngPrep.tech, this is one of the most frequently asked SQL interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.