Avgw Function

The avgw function returns the the weighted average of a set of values.


The syntax of the avgw function is

avgw(x [,w])

x are the values for which the weighted average shall be calculated.
Null values are ignored.
If the number of values is zero, the function returns null.
w are the weights. If no value is provided, the weight is assumed to be 1.


SELECT country, avgw(price, volume)
  FROM sales
  GROUP BY country;