The MEDIAN function is especially useful in cases where a small set of outliers could drastically skew the average if calculated as a mean.
MEDIAN can be used to aggregate facts in the same way as SUM, MAX, MIN, or AVG, but it also accepts metrics or entire metric expressions as arguments.
Returns the middle value of a set of data, such that half of the values are smaller and half of the values are larger. For sets with an even number of values, the median is calculated by finding the mean of the middle two values.
SELECT MEDIAN(Cost) BY ALL OTHER
SELECT MEDIAN(Date (Closed) - Date (Opened)) BY Ticket_ID
SELECT MEDIAN(Payment) BY Customer FOR PREVIOUS(Month)