MEDIAN [analytic]
For each row, returns the median value of a value set within each partition.
For each row, returns the median value of a value set within each partition. MEDIAN determines the argument with the highest numeric precedence, implicitly converts the remaining arguments to that data type, and returns that data type.
MEDIAN is an alias of
PERCENTILE_CONT [analytic] with an argument of 0.5 (50%).
Behavior type
ImmutableSyntax
MEDIAN ( expression ) OVER ( [ window-partition-clause ] )
Parameters
expression- Any
NUMERICdata type or any non-numeric data type that can be implicitly converted to a numeric data type. The function returns the middle value or an interpolated value that would be the middle value once the values are sorted. Null values are ignored in the calculation. OVER()- If the
OVERclause specifieswindow-partition-clause,MEDIANgroups input rows according to one or more columns or expressions. If this clause is omitted, no grouping occurs andMEDIANprocesses all input rows as a single partition.
Examples
See Calculating a median value