Some SQL databases have a PERCENTILE_DISC()
function that calculates a percentile based on a discrete distribution of a range of column values.
We specify the percentile to use when we call the function.
Depending on the DBMS, PERCENTILE_DISC()
can be used as a window function, as an aggregate function, or as both.
The PERCENTILE_DISC()
function always returns a value from the underlying data. This is in contrast to the PERCENTILE_CONT()
function, which can interpolate between adjacent values to return a value that’s not in the underlying data.