ARRAY_MEDIAN()
All functions > ARRAY > ARRAY_MEDIAN()
Returns the statistical median of numeric array elements as a DOUBLE.
Signatures
Returns: Median value
ARRAY_MEDIAN(array: ARRAY<T>) → DOUBLE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<T> | Yes | Numeric array |
Notes
- Ignores NULL elements
- For an even number of values, returns the average of the two middle values
- Returns NULL for an empty array or an array of only NULLs
See also
Examples
FeatureQL
SELECT
f1 := ARRAY_MEDIAN(ARRAY[3, 1, 2]) -- Odd-length median
;Result
| f1 VARCHAR |
|---|
| 2.0 |
On this page