percentile_cont(fraction
) WITHIN GROUP (ORDER BY sort_expression
)
percentile_disc(fraction
) WITHIN GROUP (ORDER BY sort_expression
)
percentile_disc returns a value in your set/window, whereas percentile_cont will interpolate
SELECT PERCENTILE_DISC (0.5) WITHIN GROUP (ORDER BY num)FROM ( SELECT * FROM generate_series (1, 10) num ) A
result: 5
SELECT PERCENTILE_CONT (0.5) WITHIN GROUP (ORDER BY num)FROM ( SELECT * FROM generate_series (1, 10) num ) A
reslult: 5.5