Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (Français) » SQL Anywhere Server - SQL Reference » Using SQL » SQL functions » SQL functions (A-D)


AVG function [Aggregate]

Computes the average, for a set of rows, of a numeric expression or of a set of unique values.

Syntax 1
AVG( numeric-expression | DISTINCT numeric-expression )
Syntax 2
AVG( numeric-expression ) OVER ( window-spec )
window-spec : see Syntax 2 instructions in the Remarks section below
  • numeric-expression   The expression whose average is calculated over a set of rows.

  • DISTINCT clause   Computes the average of the unique numeric values in the input.


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.

Syntax 2 represents usage as a window function in a SELECT statement. As such, elements of window-spec can be specified either in the function syntax (inline), or in conjunction with a WINDOW clause in the SELECT statement. See the window-spec definition provided in WINDOW clause.

For more information about using window functions in SELECT statements, including working examples, see Window functions.

See also
Standards and compatibility
  • SQL/2003   Core feature. Syntax 2 is feature T611.


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: