VeloDB Cloud
SQL Manual
Functions
aggregate-functions
PERCENTILE

PERCENTILE

Description

Syntax:

PERCENTILE(expr, DOUBLE p)

This function calculates the exact percentile. It is suitable for small data volumes. It sorts the specified column in descending order first, and then takes the exact p percentile. The value of p is between 0 and 1.

Parameter Description: expr: required. The value is an integer (bigint at most). p: The exact percentile is required. The const value is [0.0,1.0]

Example

MySQL > select `table`, percentile(cost_time,0.99) from log_statis group by `table`;
+---------------------+---------------------------+
| table    |         percentile(`cost_time`, 0.99)|
+----------+--------------------------------------+
| test     |                                54.22 |
+----------+--------------------------------------+

MySQL > select percentile(NULL,0.3) from table1;
+-----------------------+
| percentile(NULL, 0.3) |
+-----------------------+
|                  NULL |
+-----------------------+

Keywords

PERCENTILE