Computes the weighted average value of an aggregation of values and weights.


WtAvg ( n, w )


n is a numeric expression indicating the values to average, and

w is a numeric expression indicating the weight to apply to n.


WtAvg is an aggregation function which can only be used in an aggregating Select statement. Null values for n and/or w are ignored. If there are only null values supplied in the aggregation, then a null value is returned. If the denominator results in a value of zero (which would occur if the weights are zero for each record accumulated), then a value of null will be returned.

WtAvg can be replaced with the following formula: Sum ( n * w ) / Sum ( w )