aggregate

PERCENTILE_CONT

Returns a continuous quantile by interpolating between sorted non-NULL observations when needed. Fraction ranges from zero to one; numeric ordering uses double precision. Example target: PostgreSQL 17; inline synthetic data; no extensions.

Formal Syntax & Structure

sql syntaxsql
PERCENTILE_CONT(fraction) WITHIN GROUP (ORDER BY expression)

Working Example

Example Snippetsql
WITH sample(id,x,y) AS (VALUES (1,1,2),(2,2,4),(3,3,6),(4,4,8),(5,NULL,4)) SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY x) FROM sample;
SQL Reference