Computes the average of a collection of values. The keyword DISTINCT specifies that the duplicate values are to be eliminated before computing the average.
Syntax
AVG ( {[ ALL ] expression }|{ DISTINCT column_ref} )
Notes
NULL values are eliminated before the average value is computed. If all the values are NULL, the result is NULL.
The argument to the function must be of type SMALLINT, INTEGER, NUMERIC, REAL, or FLOAT.
The result is of type NUMERIC.
Example
This example illustrates the AVG function:
SELECT AVG (salary)
FROM employee
WHERE deptno = 20 ;