Recall & Review
beginner
What does the
ROWS BETWEEN clause specify in a window function?It defines the frame of rows relative to the current row by counting physical rows before and after it.
Click to reveal answer
intermediate
How does
RANGE BETWEEN differ from ROWS BETWEEN in window frames?RANGE BETWEEN defines the frame based on logical values of the ORDER BY column, including all rows with the same value, while ROWS BETWEEN counts physical rows.Click to reveal answer
beginner
What is the default window frame if none is specified?
The default is
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, meaning from the first row with the same ORDER BY value up to the current row.Click to reveal answer
beginner
Explain the effect of
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW in a window function.It includes the current row and the two rows before it in the frame for calculation.
Click to reveal answer
intermediate
Why might
RANGE BETWEEN cause unexpected results with non-unique ORDER BY values?Because it includes all rows with the same ORDER BY value, the frame can be larger than expected, affecting aggregates.
Click to reveal answer
What does
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW mean?✗ Incorrect
This frame includes all rows from the start of the partition up to the current row.
Which window frame clause counts physical rows relative to the current row?
✗ Incorrect
ROWS BETWEEN counts physical rows before and after the current row.If ORDER BY column has duplicates, which frame clause includes all rows with the same value?
✗ Incorrect
RANGE BETWEEN includes all rows with the same ORDER BY value in the frame.What is the default frame when using window functions with ORDER BY but no frame clause?
✗ Incorrect
The default frame is
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.Which clause would you use to include exactly 3 rows before and the current row in a window frame?
✗ Incorrect
ROWS BETWEEN 3 PRECEDING AND CURRENT ROW includes the current row and 3 rows before it.Describe the difference between
ROWS BETWEEN and RANGE BETWEEN in window frames.Think about counting rows versus counting values.
You got /4 concepts.
Explain why the default window frame is
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW and what it means for aggregate calculations.Consider how cumulative sums or averages work.
You got /4 concepts.