APPROX_PERCENTILE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow functions

Returns an approximated value for the desired percentile (that is, if column c has n numbers, APPROX_PERCENTILE(c, p) returns a number such that approximately n * p of the numbers in c are smaller than the returned number). This function uses an improved version of the t-Digest algorithm. For more information, see Estimating Percentile Values.

Syntax

supportedpartialnot supportednot scored

Aggregate function

APPROX_PERCENTILE( <expr> , <percentile> )

Window function

APPROX_PERCENTILE( <expr> , <percentile> ) OVER ( [ PARTITION BY <expr3> ] )

Parameters

NameRequiredDescription
exprrequiredA valid expression, such as a column name, that evaluates to a numeric value.
percentilerequiredA constant real value greater than or equal to 0.0 and less than 1.0. This indicates the percentile (from 0 to 99.999…). For example, the value 0.65 indicates the 65th percentile.
expr3requiredThis is the optional expression used to group rows into partitions.

Returns

The output is returned as a DOUBLE value.

Usage notes

See also

Referenced by