Problem Statement
In a window frame, what is the key difference between ROWS and RANGE?
Explanation
ROWS defines frames by row count relative to the current row. RANGE uses logical offsets on the ORDER BY value and often includes peer rows with the same sort key.
For precise moving windows like last 3 rows, pick ROWS. For value ranges like past 7 days by timestamp, RANGE can be appropriate when supported.
Code Solution
SolutionRead Only
SUM(amount) OVER ( ORDER BY day ROWS BETWEEN 2 PRECEDING AND CURRENT ROW ) AS moving_sum
