Has anyone found a PostgreSQL equivalent of Oracle\'s PERCENTILE_CONT function? I searched, and could not find one, so I wrote my own.
Here is the solution that I hope
With PostgreSQL 9.4 there is native support for percentiles now, implemented in Ordered-Set Aggregate Functions:
percentile_cont(fraction) WITHIN GROUP (ORDER BY sort_expression)
continuous percentile: returns a value corresponding to the specified fraction in the ordering, interpolating between adjacent input items if needed
percentile_cont(fractions) WITHIN GROUP (ORDER BY sort_expression)
multiple continuous percentile: returns an array of results matching the shape of the fractions parameter, with each non-null element replaced by the value corresponding to that percentile
See the documentation for more details: http://www.postgresql.org/docs/current/static/functions-aggregate.html