avg
Compute the average of the results for an aggregate result set
Syntax
avg([DISTINCT] arith_expr)
Arguments
| arith_expr | The arithmetic expression which will be averaged. |
Description
This function computes the average of the values of each arith_expr over all rows in each aggregate.
If distinct is specified, duplicate rows are not included in the computation.
Example
open nsfawards;
select state, avg(amount) from sponsor, award
where sponsor_nm = name
group by 1 having count(*) >= 100;
state avg(amount)
AK 358315.836734694
AL 232494.162211982
AR 213944.017241379
AZ 242658.494343504
CA 358001.58955268
CO 482200.616164629
...
VT 277214.003003003
WA 276642.719080174
WI 301120.134004648
WV 4059163.76870748
WY 222681.416230366