Watch the 7.3 Webinar On-Demand
This new release brings updates to Universal Storage, query optimization, and usability that you won’t want to miss.

MEDIAN

It is an aggregate function that returns the median of an expression (middle value in a sorted data set), which separates the higher half in a distribution from the lower half.

Syntax

MEDIAN ( expression )

Arguments

  • expression: Any numeric expression.

Return Type

Numeric value.

Examples

INSERT INTO T4 (a,b) VALUES (1,1),(1,2),(1,3),(2,1),(2,3),(2,5);

SELECT a, MEDIAN(b) FROM T4 GROUP BY a ORDER BY a;
****
+------+-----------+
| a    | MEDIAN(b) |
+------+-----------+
|    1 |    2.0000 |
|    2 |    3.0000 |
+------+-----------+