Skip Headers
Oracle® OLAP DML Reference
11g Release 2 (11.2)

Part Number E17122-05
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF


The MEDIAN function calculates the median of the values of an expression. The median is the middle number in a given sequence of numbers.

Return Value



MEDIAN(expression [CACHE] [dimension...])



The expression whose median value is to be calculated.


Specifies slightly different internal behavior. Specify this keyword only when the original performance is extremely slow.


The name of a dimension of the result; or, the name of a relation between one dimension of expression and another dimension that you want as a dimension of the result.

By default, MEDIAN returns a single value. When you indicate one or more dimensions for the result, MEDIAN calculates values along the dimensions that are specified and returns an array of values. Each dimension must be either a dimension of expression or related to one of its dimensions.


When you specify a dimension that is not an actual dimension of expression, but, instead, is dimension that is related to a dimension of expression and when there are multiple relations between the two dimensions, Oracle OLAP uses the default relation between the dimensions to perform the calculation. (See the RELATION command for more information on default relations.) When you do not want Oracle OLAP to use this default relation, specify the related dimension by specifying the name of a specify relation.

Usage Notes

NA Values and MEDIAN

MEDIAN is affected by the NASKIP option in the same manner as other aggregate functions. When NASKIP is set to YES (the default), MEDIAN ignores NA values and returns the median of the values that are not NA. When NASKIP is set to NO, MEDIAN returns NA when any value of the expression is NA. When all the values of the expression are NA, MEDIAN returns NA for either setting of NASKIP.


Example 8-24 Calculating Median Monthly Sales

This example shows how to calculate the median monthly sales of sportswear for each sales district.

LIMIT product TO 'Sportswear'
REPORT W 12 HEADING 'Median Sales' MEDIAN(sales district)

The preceding statements produce the following output.

DISTRICT          Median Sales
----------------- ------------
Boston               67,923.05
Atlanta             152,186.52
Chicago              94,372.06
Dallas              160,854.60
Denver               86,745.40
Seattle              53,950.28