Window Functions

0001-01-01

The OVER Clause: One Result Per Row Without GROUP BY

OVER turns any aggregate into a window function — computing a result across a set of rows while still returning every row intact.

0001-01-01

ROW_NUMBER, RANK, and DENSE_RANK: Three Ways to Order Rows

Three ranking functions, three different answers to ties. Pick the one that matches what your data actually means.

0001-01-01

Running Totals and Moving Averages

SUM OVER with ORDER BY gives you a running total. Add a ROWS BETWEEN frame and you get a sliding window — a moving average that looks back exactly N rows.

0001-01-01

Frame Semantics: ROWS, RANGE, and GROUPS

A window frame defines exactly which rows each window function sees. ROWS counts positions, RANGE counts values, GROUPS counts distinct peers. Mixing them up produces silent bugs.

0001-01-01

Sessionization: Grouping Events with a Running Sum

Sessionization turns a stream of timestamped events into labelled sessions using nothing but a window function — no procedural loop required.