AVG_WEIGHTED
AVG_WEIGHTEDβ
Descriptionβ
Syntaxβ
double avg_weighted(x, weight)
Calculate the weighted arithmetic mean, which is the sum of the products of all corresponding values and weights, divided the total weight sum. If the sum of all weights equals 0, NaN will be returned.
exampleβ
mysql> select avg_weighted(k2,k1) from baseall;
+--------------------------+
| avg_weighted(`k2`, `k1`) |
+--------------------------+
| 495.675 |
+--------------------------+
1 row in set (0.02 sec)
keywordsβ
AVG_WEIGHTED