Calculations across related rows.
WHAT THEY DO
Compute a value for each row, using a set of related rows, without collapsing them.
WHY THAT MATTERS
Aggregation reduces rows; window functions do not.
WHAT THE PARTS ARE
The function A partition, defining the group An ordering, where the function needs one A frame, defining which rows within the partition
WHAT THEY SOLVE ELEGANTLY
Running totals Ranking within groups Comparing a row to the previous or next Comparing a value to its group's average Deduplication, keeping one row per group
WHAT DEDUPLICATION LOOKS LIKE
Numbering rows within a group by some order, and keeping the first.
WHY THAT PATTERN MATTERS
It is one of the most useful in all of data engineering.
WHAT THE RANKING FUNCTIONS DIFFER IN
Whether ties share a rank, and whether subsequent ranks skip.
WHAT TO BE CAREFUL WITH
Frames, whose default is not always what you expect Ordering that does not determine a unique result Performance, since they require sorting
WHAT TO CHECK
That your ordering is deterministic.
WHY
Otherwise results differ between runs, unpredictably.