MEDIAN
Purpose
Takes a numeric or datetime value and returns the middle value or an interpolated value that would be the middle value after the values are sorted. Nulls are ignored in the calculation.
Type
MEDIAN is an aggregate function.
Syntax
where
Syntax element … |
Specifies … |
value_expression |
a single expression that must be a Numeric data type. |
ANSI Compliance
This is a Teradata extension to the ANSI SQL:2011 standard.
Result
The function returns the same data type as the data type of the argument.
Example
MEDIAN, an inverse distribution function that assumes a continuous distribution model, is a specific case of PERCENTILE_CONT where the percentile value is 0.5.
MEDIAN (value_expression)
is same as:
PERCENTILE_CONT (0.5) WITHIN GROUP (ORDER BY value_expression)