Postgresql: percentile_cont interpolation of values I have a couple of questions regarding percentile_cont in Postgresql. I would like to know which algorithm it uses for interpolating values when using percentile_cont ?
My second question is why is it that we have to use order by ? It just seems weird to me that it doesn't order values by default when using percentile_cont? I fail to see why this choice has been made. Would someone please explain the reason behind such a choice?
Because that is the syntax which is available for "ordered set" aggregate functions.  If the ORDER BY were removed, then it would not know what column or expression to calculate the percentile over.  I know what "the median height of a dog" means, and even "the median dog by height" (although that is of questionable utility, especially the continuous version) but what would the "median dog by no specified metric" mean?

We could invent some way of conveying that column-to-be-used information other than ORDER BY, but why do that? There is a machinery for "ordered set" aggregate functions in place, it should be used for the things that fit into it.