MEDIAN

It takes a numeric or datetime value and returns the middle value or an interpolated value that would be the middle value once the values are sorted. Nulls are ignored in the calculation.

Syntax

MEDIAN(expression)

Example

SELECT department_id, MEDIAN(salary)
   FROM employees
   GROUP BY department_id;