This function is used to approximate the pth percentile (including floating-point numbers) of a numeric column within a group.
percentile_approx(DOUBLE col, p [, B])
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. |
B |
Yes |
The parameter B controls the accuracy of the approximation, with a higher value of B resulting in a higher level of approximation. The default value is 10000. If the number of non-repeating values in the column is less than B, an exact percentile is returned. |
The return value is of the DOUBLE type.
select stddev_samp(items,0.5, 100) from warehouse;
The command output is as follows:
_c0 500
select warehourseId, stddev_samp(items, 0.5, 100) from warehourse group by warehourseId;
The command output is as follows:
warehouseId _c1 city1 499 city2 354 city3 565