Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
Computes the average, for a set of rows, of a numeric expression or of a set of unique values.
AVG( [ DISTINCT ] numeric-expression )
[ ALL ] numeric-expression
The expression whose average is calculated over the rows in each group.
Computes the average of the unique numeric values in each group.
Returns the NULL value for a group containing no rows.
Returns DOUBLE if the argument is DOUBLE, otherwise NUMERIC.
This average does not include rows where the numeric-expression is the NULL value.
This function can generate an overflow error, resulting in an error being returned. You can use the CAST function on numeric-expression to avoid the overflow error.
AVG is a core feature of the SQL/2008 standard.
The following statement returns the value 49988.623200.
SELECT AVG( Salary ) FROM Employees;
The following statement returns the average product price from the Products table:
SELECT AVG( DISTINCT UnitPrice ) FROM Products;