MEDIAN
Description
This function calculates the median per group. Median can be applied to INT, FLOAT or DATE columns.
The median is the middle element of a group. If the group has an even number of elements, the upper value of the two middle values is taken as the median.
Syntax
MEDIAN ( table.column )
NULL handling
NULL values are ignored, meaning that they do not influence the result. If all values of a group are NULL, the result for this group is also NULL.
Examples
[1] Median of column with 3 rows. | ||||||||||
| ||||||||||
|
[2] Median of column with 4 rows. If a group has an even number of entries, the upper value of the two middle values is taken. | |||||||||||
| |||||||||||
|
[3] Get the median value by country. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
|
[4] Get the median value mixed with nulls, grouped by country. | ||||||||||||||||||
| ||||||||||||||||||
|