percentile
Function
The percentile function is used to calculate the exact percentile, suitable for small data volumes. It first sorts the specified column in ascending order, then returns the exact value at the p-th percentile.
Syntax
percentile(colname,DOUBLE p)
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| colname | Yes | STRING | Represents the column name to be sorted. Elements in the column must be of integer type. |
| p | Yes | DOUBLE | The range of p is 0–1. The format of parameter p includes floating-point format. |
Return Values
Returns a value of type DOUBLE or ARRAY.
- If the column name does not exist, an error is returned.
- If p is NULL or outside [0, 1], an error is returned.
Examples
Assume the elements in column int_test are 1, 2, 3, 4, of type INT.
Returns 3.0999999999999996.
select percentile(int_test,0.7) FROM int_test;
Returns 2.5.
select percentile(int_test,0.5) FROM int_test;
Returns [1.3, 1.9, 2.5, 2.8, 3.7].
select percentile (int_test,ARRAY(0.1,0.3,0.5,0.6,0.9)) FROM int_test;
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot