Given a value expression, typically involving one or more columns, MEDIAN computes the median value of the value expression over all the rows in the query or over all the rows in a group of rows determined by a GROUP BY clause. Very loosely, the median value is the “middle” value in a set of values such that a nearly equal number of values are less than and greater than the median value. When there is an even number of values in the set of values, linear interpolation is used on the two “middle” values to determine the median.
Median is an aggregate function with NULL values ignored.
MEDIAN(expression)
is the same as:
PERCENTILE_CONT (0.5) WITHIN GROUP ORDER BY (expression)
When dragging a Median function into a variable, the following tree element is created.
There are no special properties associated with the Median function.