APPROX_TOP_K

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow functions

Uses Space-Saving to return an approximation of the most frequent values in the input, along with their approximate frequencies. The output is a JSON array of arrays. In the inner arrays, the first entry is a value in the input, and the second entry corresponds to its estimated frequency in the input. The outer array contains k items, sorted by descending frequency. For more information about APPROX_TOP_K, see Estimating Frequent Values.

Syntax

supportedpartialnot supportednot scored

Aggregate function

APPROX_TOP_K( <expr> [ , <k> [ , <counters> ] ] )

Window function

APPROX_TOP_K( <expr> [ , <k> [ , <counters> ] ] ) OVER ( [ PARTITION BY <expr4> ] )

Parameters

NameRequiredDescription
expr4requiredThis is the optional expression used to group rows into partitions.

Usage notes

See also

Referenced by