Custom Search
Showing posts with label The SQL AVG Function Statement. Show all posts
Showing posts with label The SQL AVG Function Statement. Show all posts

Saturday, August 23, 2008

SQL AVG Function

The AVG function returns the average value of a column in a selection. NULL values are not included in the calculation.

Syntax

SELECT AVG(column) FROM table

Example

This example returns the average age of the persons in the "Persons" table:

SELECT AVG(Age) FROM Persons

Result

32.67

Example

This example returns the average age for persons that are older than 20 years:

SELECT AVG(Age) FROM Persons WHERE Age>20

Result

39.5