Example
Return the average value for the "Price" column in the "Products" table:
sql
SELECT AVG(Price) AS
AveragePrice FROM Products;
Definition and Usage
The AVG() function returns the average value of an expression.
Note: NULL values are ignored.
Syntax
text
AVG(expression)
Parameter Values
| Parameter | Description |
|---|---|
| expression | Required. A numeric value (can be a field or a formula) |
Technical Details
| Works in: | From MySQL 4.0 |
|---|
More Examples
Example
Select the records that have a price above the average price:
sql
SELECT * FROM Products
WHERE Price > (SELECT AVG(Price) FROM Products);