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

  1. mysql >select * from quantile_weighted_table order by k;
  2. +------+------+
  3. | k | w |
  4. +------+------+
  5. | 1 | 2 |
  6. | 3 | 1 |
  7. | 5 | 2 |
  8. +------+------+
  9. mysql >select percentile_approx_weighted(k,w,0.55) from quantile_weighted_table;
  10. +----------------------------------------------------------------------------------------+
  11. | percentile_approx_weighted(cast(k as DOUBLE), cast(w as DOUBLE), cast(0.55 as DOUBLE)) |
  12. +----------------------------------------------------------------------------------------+
  13. | 3.3333332538604736 |
  14. +----------------------------------------------------------------------------------------+

keywords

PERCENTILE_APPROX,PERCENTILE,APPROX,PERCENTILE_APPROX_WEIGHTED