Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

AVG

Example

Calculate and return the average value of the “Price” column in the “Products” table.

SELECT AVG(Price) AS AveragePrice FROM Products;

Definition and Usage

The AVG() function calculates and returns the average value of a given expression.

Note that NULL values are excluded from the calculation by the AVG() function.

Syntax

AVG(expression)

Parameter Values

Parameter

Description

expression

Required. A numerical value, which can be a field or a formula, used to calculate the average.

Technical Details

Works in:

Available in SQL Server from 2008 onward, as well as in Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse.

More Examples

Example

Retrieve all products whose price exceeds the average price of all products.

SELECT * FROM Products
WHERE Price > (SELECT AVG(Price) FROM Products);