Compose OVER (PARTITION BY ... ORDER BY ... ROWS BETWEEN ...) clauses visually. See the generated SQL and the result it would produce on sample data — running totals, rankings, lags, and moving averages.
Computed in your browser against a small orders sample. Highlighted column shows the window function output. Horizontal lines mark PARTITION BY boundaries.
| Frame | Use case |
|---|---|
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | Running total / cumulative sum |
ROWS BETWEEN N PRECEDING AND CURRENT ROW | Trailing N-row moving average |
ROWS BETWEEN N PRECEDING AND N FOLLOWING | Centered window (smoothing) |
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING | Remaining-rows total |
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | Default for aggregates with ORDER BY (peer-group inclusive) |