SQL AVG() Function

The AVG() function returns the average value of a numeric column.

SQL AVG() Syntax

SELECT AVG(column_name) FROM table_name

SQL AVG() Example

The following SQL statement gets the average value of the “Price” column from the “Products” table:

Example

SELECT AVG(Price) AS PriceAverage FROM Products;

The following SQL statement selects the “ProductName” and “Price” records that have an above average price:

Example

SELECT ProductName, Price FROM Products
WHERE Price>(SELECT AVG(Price) FROM Products);