PERCENTILECONT
PERCENTILECONT refers to the PostgreSQL percentile_cont function, a window and aggregate function used to compute a percentile for a set of values by linearly interpolating between ordered values. It provides a continuous percentile, in contrast to discrete percentiles returned by certain other functions.
The typical usage is percentile_cont(percentile) WITHIN GROUP (ORDER BY sort_expression), where percentile is a number between
Behavior and return type: The percentile parameter must lie in the range [0, 1]. NULL values are
How it works: percentile_cont computes the percentile by linearly interpolating between adjacent values in the ordered
- Median salary: SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY salary) FROM employees;
- 90th percentile by department: SELECT dept, percentile_cont(0.9) WITHIN GROUP (ORDER BY salary) OVER (PARTITION BY dept)
See also: percentile_disc, which computes discrete percentiles without interpolation, and other standard SQL percentile functions.