window frame
The subset of a partition that a window calculation sees for each row, such as the current row and the one before it.
In more detail
A frame of one preceding row and the current row makes a moving two-row window. The first row of a partition has no row before it, so frames are incomplete at the edges; test those boundary rows.
Example
SUM(id) OVER (ORDER BY id ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)Related terms
- OVER — The clause that makes a function a window function and defines which rows it can see and in what order.
- window function — A calculation across a set of rows related to the current row that, unlike GROUP BY, keeps every input row in the answer.
- running total — A total that grows row by row, adding each row's value to the sum of all rows before it.
Taught in
- Advanced Window Functions: Ranking And Framing — PostgreSQL, Indexing & Relational Data Modeling