APPROX_TOP_K_ESTIMATE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow function syntax and usage

Returns the approximate most frequent values and their estimated frequency for the given Space-Saving state. (For more information about the Space-Saving summary, see Estimating Frequent Values.) A Space-Saving state produced by APPROX_TOP_K_ACCUMULATE and APPROX_TOP_K_COMBINE can be used to compute a cardinality estimate using the APPROX_TOP_K_ESTIMATE function. Thus, APPROX_TOP_K_ESTIMATE(APPROX_TOP_K_ACCUMULATE(…)) is equivalent to APPROX_TOP_K(…).

Syntax

supportedpartialnot supportednot scored

APPROX_TOP_K_ESTIMATE( <state> [ , <k> ] )

Parameters

NameRequiredDescription
staterequiredAn expression that contains state information generated by a call to APPROX_TOP_K_ACCUMULATE or APPROX_TOP_K_COMBINE.
krequiredThe number of values whose counts you want approximated. For example, if you want to see the top 10 most common values, then set k to 10. If k is omitted, the default is 1. The maximum value is 100000 (100,000), and is automatically reduced if items cannot fit in the output.

Returns

Returns a value of type ARRAY.

Usage notes

See also

Referenced by