Window Functions: Compute Without Collapsing
Aggregate functions are powerful, but they come with a cost: when you ask for a summary, you lose the detail. Window functions remove that trade-off. ...
#11 SQLRanking Rows in SQL: ROW_NUMBER, RANK, DENSE_RANK, and NTILE
A window function computes a value across a set of related rows without collapsing them — each row keeps its place in the output, but gains a calculat...
#12 SQLLooking Back and Forward: LAG() and LEAD() in SQL
Most window functions look at the current row and summarise its neighbours. LAG() and LEAD() do something more direct: they reach out and grab a value...
#13 SQLWindow Frames in SQL: ROWS, RANGE, and GROUPS
Every window function operates within a window — but not every window function reads the frame. The frame is the specific subset of rows a frame-sensi...
#14 SQLFIRST_VALUE, LAST_VALUE, and NTH_VALUE: Reading Values by Position
Sometimes you don't want to compute a value across a window, you want to reach in and grab one from a specific position: the first row, the last row, ...