Updated on 2026-11-06 GMT+08:00

median

Function

The median function is used to calculate the median of the input parameters.

Syntax

median(colname)

Parameters

Parameter

Mandatory

Type

Description

colname

Yes

DOUBLE, DECIMAL, STRING, or BIGINT

Represents the column name to be sorted. Elements in the column are of type DOUBLE. When elements in the column are not of type DOUBLE, they are implicitly converted to DOUBLE type before computation.

Return Values

Returns a value of type DOUBLE or DECIMAL.

If the column name does not exist, an error is returned.

Examples

Assume the elements in column int_test are 1, 2, 3, 4, of type INT.

Returns 2.5.

select median(int_test) FROM int_test;