Percentile disc postgresql
To get the median, use a percentile function. The syntax for the percentile functions is different than for other functions you've seen because the data must be ordered to do the computation. It's called ordered set aggregate syntax. The only argument to the function is a number between 0 and 1 corresponding to the percentile you want. You then type "within group", and then, inside parentheses, order by and the name of the column you want to compute the percentile for. PERCENTILE_DISC, or discrete, always returns a value that exists in the column.