Practice vocabulary for SQL window functions including OVER, PARTITION BY, ROW_NUMBER, RANK, LAG/LEAD, and running totals.
0 / 5 completed
1 / 5
The clause that defines the frame of rows a window function operates over is the _____ clause.
OVER (...) is the mandatory clause that turns an aggregate or ranking function into a window function, defining the partition and ordering of the window.
2 / 5
You want to rank rows within each department independently. Which clause inside OVER achieves this?
PARTITION BY resets the window function's calculation for each distinct value of the partition column — similar to GROUP BY but without collapsing rows.
3 / 5
What is the difference between RANK() and DENSE_RANK() when there are ties?
RANK leaves gaps after ties (e.g., 1, 2, 2, 4), while DENSE_RANK assigns consecutive integers without gaps (e.g., 1, 2, 2, 3).
4 / 5
Which window function pair allows you to access the value from the previous or next row without a self-join?
LAG accesses the value from a preceding row and LEAD accesses a following row within the defined window, eliminating the need for a self-join.
5 / 5
A window function with SUM(...) OVER (ORDER BY date) computes a _____.
SUM with an ORDER BY inside OVER creates a running total (cumulative sum) — each row's value is the sum of all rows up to and including the current one.