PERCENTILE_CONT
Given an ordered set of values, this aggregate function returns the continuous percentile
value, which is the value from the set that corresponds to the specified fraction. For
example, percentile_cont(0.5)
returns the median value. If necessary, the
percentile value is interpolated in the set. See also MEDIAN() and PERCENTILE_DISC.
percentile_cont(fraction) WITHIN GROUP (ORDER BY sort_expression)
Specify a fraction between 0
and 1
. The sort expression
data type must be numeric.
For example:
premdb=# select max(avg_att), min(avg_att),
percentile_cont(0.2) within group (order by avg_att) from team where avg_att>0;
max | min | percentile_cont
--------+--------+-----------------
75.286 | 11.189 | 24.635
(1 row)
premdb=# select max(avg_att), min(avg_att),
percentile_cont(0.9) within group (order by avg_att) from team where avg_att>0;
max | min | percentile_cont
--------+--------+-----------------
75.286 | 11.189 | 54.6313
(1 row)