Skip to content

Percentile

AggregationDialect-gated

Percentile(column, p)

The value below which a fraction p of the column falls (Percentile(x, 0.5)Median). p must be a literal strictly between 0 and 1 (SQX013).

Each engine gets its own native spelling — exact where the database has an exact grouped form, the engine’s own quantile function elsewhere:

Engine Compiles to Exactness
PostgreSQL · Redshift · Oracle · Snowflake PERCENTILE_CONT(p) WITHIN GROUP (ORDER BY col) exact
Databricks PERCENTILE(col, p) exact
Databend QUANTILE_CONT(p)(col) exact
ClickHouse quantile(p)(col) approximate
Trino / Presto approx_percentile(col, p) approximate
Druid APPROX_QUANTILE_DS(col, p) approximate
StarRocks PERCENTILE_APPROX(col, p) approximate
Vertica APPROXIMATE_PERCENTILE(col USING PARAMETERS percentile=p) approximate
Pinot PERCENTILE(col, p × 100) scale handled for you
CrateDB percentile(col, p) native aggregate
MySQL · SQL Server · BigQuery fails loudly (SQX010)

On the last three, PERCENTILE_CONT is window-only (or absent) — SquareX refuses to fake a grouped percentile rather than silently compute something different.

  • SLA / SLO reporting — P90 delivery days, P95 response time, P99 latency.
  • Distribution cutoffs — what does a top-decile order look like? (Percentile(Sales.Amount, 0.9)).
P90OrderValue := Percentile(Sales.Amount, 0.9)
// On a bar chart grouped by order type
P90OrderValue := Percentile(Sales.Amount, 0.9)
  • Non-additive — rejected under YTD/RollingSum (SQX015).