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]
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 | +-----------------------+
PERCENTILE