Skip to content

MEDIAN()

Return the median value from an ordered set, equivalent to percentile_cont(0.5). The results of median() and percentile_cont(0.5) are always the same.

MEDIAN() WITHIN GROUP (ORDER BY sort_expression)

See PERCENTILE_CONT.

For example:

premdb=# select median() within group (order by avg_att) from team where avg_att>0;
 percentile_cont 
-----------------
           34.3
(1 row)