avg() or sum().
Functions
| Function | Arguments | Returns | Description |
|---|---|---|---|
median(Y) | Y — numeric column | REAL or NULL | The median (middle value) of all non-NULL values in the group |
percentile(Y, P) | Y — numeric column; P — percentile 0–100 | REAL or NULL | The P-th percentile of Y using linear interpolation |
percentile_cont(Y, P) | Y — numeric column; P — fraction 0.0–1.0 | REAL or NULL | Continuous percentile using linear interpolation; P is a fraction |
percentile_disc(Y, P) | Y — numeric column; P — percentile 0–100 | REAL or NULL | Discrete percentile; returns the largest value in Y at or below the P-th percentile |
stddev(Y) | Y — numeric column | REAL or NULL | Sample standard deviation using Welford’s algorithm; returns NULL if fewer than 2 values |
Difference between percentile variants
percentile(Y, P)—Pis on a 0–100 scale. Uses linear interpolation between adjacent values. This is the most common form.percentile_cont(Y, P)—Pis on a 0.0–1.0 scale (fractional). Uses the same linear interpolation aspercentilebut with a different scale.percentile_disc(Y, P)—Pis on a 0–100 scale. Returns an actual value from the dataset (the floor of the interpolated position) rather than interpolating between values.
The
P argument must be consistent across all rows in a group. Passing different P values in the same aggregation group is an error.Examples
Median
Percentile (0–100 scale)
Percentile continuous (0.0–1.0 scale)
Percentile discrete
Standard deviation
NULL handling
All functions ignore NULL values during aggregation. If the group is empty (or all values are NULL), the functions return NULL.stddev returns NULL when the group contains fewer than 2 non-NULL values, because sample standard deviation is undefined for a single data point.