SORTMIDDLE(value_exp)

Returns the Middle Item in the Sorted Population of value_exp.

Description

This function returns the middle value of the sorted population of n elements.

SortMiddle will return the (n+1)/2'th value, performing integer division.

 

Example

V1

V2

V3

V4

V5

V6

5

25

2

1

0

30

 

The above example would return 2, because it is the 3th value in the sorted population ((6+1)/2 = 3.5 ~=3).

 

V1

V2

V3

V4

V5

5

25

2

25

25

The above example would return 25, because it is the 3rd value in the population ((5+1)/2 = 3).

 

Parameters

value_exp can be an expression of any SQL data type.