Chapter 4: SQL Language Elements
4.9.1.1 AVG
Syntax
AVG ( { [ALL] expression } | { DISTINCT column_ref } )
Description
The aggregate function AVG computes the average of a collection of values. The keyword DISTINCT specifies that the duplicate values are to be eliminated before computing the average.
- 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
SELECT AVG (salary)
FROM employee
WHERE deptno = 20 ;