Oracle/PLSQL: Median Function
In Oracle/PLSQL, the median function returns the median of an expression.
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 10g, Oracle 11g
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.
