Friday, January 11, 2013

Median Function


In Oracle/PLSQL, the median function returns the median of an expression.

Syntax

The syntax for the median function is:
median( expression ) [ OVER ( query partition clause ) ]

Note

The median function is NEW to Oracle 10! In older versions of Oracle, try using the percentile_cont function to calculate the median value.

Applies To

  • Oracle 11g, Oracle 10g

For Example

select median(salary)
from employees
where department = 'Marketing';
The SQL statement above would return the median salary for all employees in the Marketing department.