为什么80%的码农都做不了架构师?>>>
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
SELECTPERCENTILE_DISC (0.5) WITHIN GROUP (ORDER BY num)
FROM(SELECT*FROMgenerate_series (1, 10) num) A
result: 5
SELECTPERCENTILE_CONT (0.5) WITHIN GROUP (ORDER BY num)
FROM(SELECT*FROMgenerate_series (1, 10) num) A
reslult: 5.5