Skip to main content

Window functions

Window functions perform calculations across a set of rows related to the current row.

ROW_NUMBER

Assigns a unique sequential number to each row within a partition.

RANK

Assigns a rank with gaps for ties.

DENSE_RANK

Assigns a rank without gaps for ties.

PERCENT_RANK

Returns the relative rank as a percentage (0 to 1).

LAG

Returns the value from a previous row.

LEAD

Returns the value from a following row.

SUM / AVG / COUNT (windowed)

Aggregate functions can be used as window functions.

Aggregate Functions

GROUP BY computations

SELECT

QUALIFY clause for window function filtering

All Functions

Browse all function categories

Common Query Patterns

Real-world deduplication examples