This function is used to return the numerical value at a certain percentage point within a range of values.
percentile(BIGINT col, p)
Parameter |
Mandatory |
Description |
|---|---|---|
col |
Yes |
Columns with a data type of numeric. If the values are of any other type, NULL is returned. |
p |
Yes |
The value should be between 0 and 1. Otherwise, NULL is returned. |
The return value is of the DOUBLE type.
The value should be between 0 and 1. Otherwise, NULL is returned.
select percentile(items,0.5) from warehouse;
The command output is as follows:
+------------+ | _c0 | +------------+ | 500.6 | +------------+
select warehouseId, percentile(items, 0.5) from warehouse group by warehouseId;
The command output is as follows:
+------------+------------+ | warehouseId| _c1 | +------------+------------+ | city1 | 499.6 | | city2 | 354.8 | | city3 | 565.7 | +------------+------------+