Skip to main content
Skip to main content

PERCENTILE_APPROX_WEIGHTED

PERCENTILE_APPROX_WEIGHTED​

description​

Syntax​

PERCENTILE_APPROX_WEIGHTED(expr, w ,DOUBLE p [, DOUBLE compression])

The function is similar to PERCENTILE_APPROX, with the only difference being an additional parameter w, which represents the number of times expr appears. Note that the value of parameter W needs to be greater than 0. If the value of a row is less than or equal to 0 during the calculation process, the current row will be skipped.

example​

mysql >select * from quantile_weighted_table order by k;
+------+------+
| k | w |
+------+------+
| 1 | 2 |
| 3 | 1 |
| 5 | 2 |
+------+------+


mysql >select percentile_approx_weighted(k,w,0.55) from quantile_weighted_table;
+----------------------------------------------------------------------------------------+
| percentile_approx_weighted(cast(k as DOUBLE), cast(w as DOUBLE), cast(0.55 as DOUBLE)) |
+----------------------------------------------------------------------------------------+
| 3.3333332538604736 |
+----------------------------------------------------------------------------------------+

keywords​

PERCENTILE_APPROX,PERCENTILE,APPROX,PERCENTILE_APPROX_WEIGHTED