OVER ... ROWS / RANGE frame
ROWS (physical offsets) or RANGE (logical peers) frame bounds
What changes
- Input
- ordered partition rows
- Output or change
- frame per row
Syntax at a glance
{ ROWS | RANGE } { UNBOUNDED PRECEDING | n PRECEDING | CURRENT ROW | BETWEEN <frame_bound> AND <frame_bound> }
Work example
A report needs OVER ... ROWS / RANGE frame to calculate a row-aware value without collapsing detail rows.
Choose PARTITION BY, ORDER BY, and a frame explicitly. Compare the first and last row in each partition.
Check your work OVER ... ROWS / RANGE frame. The output keeps the input row count and each OVER ... ROWS / RANGE frame value matches its partition and frame.
Open Microsoft Learn for full syntax, permissions, and details for your version.