Frame Clauses: ROWS vs RANGE
Choose between ROWS BETWEEN and RANGE BETWEEN frame clauses, and understand how each handles duplicates and gaps.
The Frame Inside OVER
A window function evaluates over a frame — a subset of rows from the partition. The frame is defined by:
OVER (
PARTITION BY ...
ORDER BY ...
ROWS BETWEEN <start> AND <end> -- or RANGE BETWEEN ...
)Default Frame
If you specify ORDER BY but no frame, the default is:
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
-- "From the first row up to all rows tied with the current row".All lessons in this course
- Frame Clauses: ROWS vs RANGE
- Lag/Lead with Frame Windows
- Bucketing with NTILE and Cume_Dist
- Real-World Reporting Patterns