This function is used to calculate the median of input parameters.
median(colname)
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
colname |
Yes |
DOUBLE, DECIMAL, STRING, or BIGINT |
Name of the column to be sorted The elements in a column are of the DOUBLE type. If an element in a column is not of the DOUBLE type, the system will implicitly convert it to the DOUBLE type for calculation. |
The return value is of the DOUBLE or DECIMAL type.
If the column name does not exist, an error is reported.
Assume that the elements in the int_test column are 1, 2, 3, and 4 and they are of the INT type.
The value 2.5 is returned.
select median(int_test) FROM int_test;