PERCENTILE

Description

Syntax

PERCENTILE(expr, DOUBLE p)

Calculate the exact percentile, suitable for small data volumes. Sort the specified column in descending order first, and then take the exact p-th 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 value is [0.0,1.0]

example

1. MySQL > select `table`, percentile(cost_time,0.99) from log_statis group by `table`;
2. +---------------------+---------------------------+
3. | table    |         percentile(`cost_time`, 0.99)|
4. +----------+--------------------------------------+
5. | test     |                                54.22 |
6. +----------+--------------------------------------+

8. MySQL > select percentile(NULL,0.3) from table1;
9. +-----------------------+
10. | percentile(NULL, 0.3) |
11. +-----------------------+
12. |                  NULL |
13. +-----------------------+

keyword

PERCENTILE