PERCENTILE_CONT
Finds the median or another percentile — the value below which a given share of the data lies.
Syntax
PERCENTILE_CONT(<fraction>) WITHIN GROUP (ORDER BY <expression>)
PERCENTILE_CONT(0.5) is the median: half the values are smaller, half are larger. Unlike the average, a single very large value doesn't shift it. The function can return a number between two existing ones; if you need exactly one of the existing values, use PERCENTILE_DISC.