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.
DISTINCT clause 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. See CAST function [Data type conversion].
SQL/2008 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; |
![]() |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |