Window functions¶

Window functions are analytic functions that you can use for various calculations such as running totals, moving averages, and rankings.

For general syntax rules, see Window function syntax and usage. For syntax specific to individual functions, go to the links in the following table.

Sub-category

Notes

General window

Uses WITHIN GROUP syntax.

Uses WITHIN GROUP syntax.

Uses WITHIN GROUP syntax.

STDDEV and STDDEV_SAMP are aliases.

Alias for VAR_POP.

Alias for VAR_SAMP.

Ranking

Supports only RANGE BETWEEN window frames without explicit offsets.

Bitwise aggregation

Boolean aggregation

Hash

Semi-structured data aggregation

Counting distinct values

Linear regression

Statistics and probability

Cardinality estimation . (using HyperLogLog)

Alias for HLL.

Not an aggregate function; uses scalar input from HLL_ACCUMULATE or HLL_COMBINE.

Similarity estimation . (using MinHash)

Alias for APPROXIMATE_SIMILARITY.

Frequency estimation . (using Space-Saving)

Not an aggregate function; uses scalar input from APPROX_TOP_K_ACCUMULATE or APPROX_TOP_K_COMBINE.

Percentile estimation . (using t-Digest)

Not an aggregate function; uses scalar input from APPROX_PERCENTILE_ACCUMULATE or APPROX_PERCENTILE_COMBINE.