Calculate and return the average value of the “Price” column in the “Products” table.
SELECT AVG(Price) AS AveragePrice FROM Products; |
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.
AVG(expression) |
Parameter |
Description |
expression |
Required. A numerical value, which can be a field or a formula, used to calculate the average. |
Works in: |
Available in SQL Server from 2008 onward, as well as in Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse. |
Retrieve all products whose price exceeds the average price of all products.
SELECT * FROM Products |