Export (0) Print
Expand All

Median

SQL Server 2000

Median

  Topic last updated -- July 2003

Returns the median value of a numeric expression evaluated over a set.

Syntax

Median(«Set»[, «Numeric Expression»])

Remarks

The Median function returns the median value of a numeric expression that is specified in «Numeric Expression» and evaluated over a set specified in «Set». The median value is the middle value in a set of ordered numbers (unlike the mean value, which is the sum of a set of numbers divided by the count of numbers in the set). The median value is determined by choosing the smallest value such that at least half of the values in the set are no greater than the chosen value. If the number of values within the set is odd, the median value corresponds to a single value. If the number of values within the set is even, the median value corresponds to the sum of the two middle values divided by two.

Example

The following example, a calculated member that is executed against the Sales cube of the FoodMart 2000 database, returns the median value of the Unit Sales measure for the children of the Juice member in the Product dimension:

WITH MEMBER [Measures].[MedianJuiceUnitSales] AS 
'MEDIAN(Product.Juice.CHILDREN, Measures.[Unit Sales])' 
Show:
© 2014 Microsoft