Tag archive
Commands grouped around the same concept, pattern, or recurring problem.
Reference values from preceding or following rows within an ordered partition without writing a self-join.
Accumulate a column's values row by row using `SUM` as a window function.
Use `SUM(...) OVER ()` to compare each row's value to the total without collapsing the result set.
Create stable run groups without a primary key by subtracting two `ROW_NUMBER()` calculations over the same ordered events.
Assign sequential integers to rows within a partition without collapsing the result set the way `GROUP BY` does.
Assign rank numbers to rows within a partition, controlling whether tied ranks leave gaps in the sequence.
Use `ROW_NUMBER()` to rank rows within each group and keep only the highest-ranked row.