> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PERCENTILE_CONT

> Returns exact interpolated quantiles of non-NULL numeric values.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Aggregate · Window</span></div>

NULL values are ignored. An empty input returns NULL, whether requesting one percentile or an array of percentiles.

## Syntax

A window function keeps each input row and adds a result for that row. `PARTITION BY` groups rows with matching values; without it, all input rows form one group.

### Aggregate

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
percentile_cont(percentile) WITHIN GROUP (ORDER BY value [ASC | DESC])
```

### Window

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
percentile_cont(percentile) WITHIN GROUP (ORDER BY value [ASC | DESC]) OVER ([PARTITION BY key] [ROWS frame])
```

* WITHIN GROUP specifies the value order. Do not add a conflicting ORDER BY inside OVER.
* Sliding ROWS frames are supported. This function does not accept a frequency argument.
* RANGE frames with a numeric or time offset are not supported.

## Arguments

### Aggregate and window

| Name | Type | Required | Description |
| - | - | - | - |
| percentile | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s), or ARRAY\<DOUBLE> | Yes | A constant fraction in \[0, 1], or a constant array of fractions. Numeric fractions are converted to DOUBLE. Use a scalar fraction when requesting a single percentile: an array containing one fraction currently raises a result-type error. |
| value | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | Values to order. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

## Returns

* Type: A scalar fraction returns DOUBLE for integer inputs, or the input’s effective FLOAT, DOUBLE, or DECIMAL type for floating-point and decimal inputs. An array of fractions returns an ARRAY of the corresponding result type.
* NULL behavior: NULL values are ignored. An empty input returns NULL, whether requesting one percentile or an array of percentiles.
* Empty input: Returns NULL on empty input.
* Shape: Scalar fraction gives scalar; array fractions give matching-length array.
* Ordering: Array results follow requested fraction order. DESC reverses percentile orientation.

## Properties

| Property | Value |
| - | - |
| Deterministic | Partial (Floating-point calculations can differ slightly because of rounding.) |
| Supports DISTINCT | No |
| Supports window usage | Yes |
| Supports window frames | Partial (Sliding ROWS frames are supported. RANGE offsets are not supported.) |
| Exact result | Partial (Floating-point arithmetic can round.) |

## Usage notes

* Exact computation retains values and memory grows with input size.
* Integer values are converted to DOUBLE. Large integers can lose precision.
* Use [PERCENTILE](/query/sql/functions/aggregate/percentile) when each value has a frequency or weight.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
* DISTINCT is not accepted in this function’s syntax. To calculate percentiles over unique values, remove duplicates in a subquery.
* In a window call, the WITHIN GROUP ordering determines which values are used for the percentile and supplies the window ordering.

## Examples

### Basic example

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t("value") AS (VALUES (0),(1),(2),(10)) SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY "value") AS result FROM t;
```

| result |
| - |
| 1.5 |

### Request multiple percentiles as an array

The result follows the order of the requested fractions. For a single percentile, pass a scalar fraction instead of a one-element array.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t(v) AS (VALUES (0), (1), (2), (10)) SELECT percentile_cont(array(0.5, 0.4, 0.1)) WITHIN GROUP (ORDER BY v) AS result FROM t;
```

| result |
| - |
| \[1.5,1.2,0.3] |

## Limitations

* Floating-point and decimal results keep their effective input type, even when query tools report DOUBLE or ARRAY\<DOUBLE>. The reported type does not convert the result.
* Fractions must be constant expressions; they cannot vary by row.
* An array containing exactly one fraction currently raises a result-type error. Pass a scalar fraction for one percentile, or use separate scalar calls when selecting several percentiles.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.