median
This function is used to calculate the median of input parameters.
Syntax
median(colname)
Parameters
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. |
Return Values
The return value is of the DOUBLE or DECIMAL type.
![](https://support.huaweicloud.com/eu/sqlreference-dli/public_sys-resources/note_3.0-en-us.png)
If the column name does not exist, an error is reported.
Example Code
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;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.