PERCENTILE_DISC

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow functions

Returns a percentile value based on a discrete distribution of the input column (specified in order_by_expr). The returned value is that whose row has the smallest CUME_DIST value that is greater than or equal to the given percentile. NULL values are ignored in the calculation.

Syntax

supportedpartialnot supportednot scored

Aggregate function

PERCENTILE_DISC( <percentile> ) WITHIN GROUP (ORDER BY <order_by_expr> )

Window function

PERCENTILE_DISC( <percentile> )
  WITHIN GROUP (ORDER BY <order_by_expr> )
  OVER ( [ PARTITION BY <expr3> ] )

Parameters

NameRequiredDescription
percentilerequiredThe percentile of the value that you want to find. The percentile must be a constant between 0.0 and 1.0. For example, if you want to find the value at the 90th percentile, specify 0.9.
order_by_exprrequiredThe expression (typically a column name) by which to order the values. For example, if you want to want to find the student whose math SAT score is at the 90th percentile, then specify the column containing the math SAT score. Note that this is also implicitly the column from which the returned value is chosen. For example, if you order by math SAT scores, then the result is one of the math SAT scores. You cannot order by one column and get a percentile value for a different column.
expr3requiredThis is the optional expression used to group rows into partitions.

Returns

Returns the value that is at the specified percentile.

Usage notes

See also

Referenced by