Oracle / PLSQL: MEDIAN Function

This article is written about how to use the Oracle/PLSQL MEDIAN function with syntax and examples.


The Oracle/PLSQL MEDIAN function returns the median of an expression.


The syntax for the MEDIAN function in Oracle/PLSQL is:

MEDIAN( expression ) [ OVER ( query partition clause ) ]

Parameters or Arguments


The value used to calculate the median.


The MEDIAN function returns a numeric or date value.


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

The MEDIAN function can be used in the following versions of Oracle/PLSQL:

Oracle 12c, Oracle 11g, Oracle 10g


Let’s look at some Oracle MEDIAN function examples and explore how to use the MEDIAN function in Oracle/PLSQL.

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.