MS Access Avg() Function
The Avg()
function in MS Access calculates the average (mean) of a set of numeric values. It's a very common aggregate function used to summarize numerical data.
Avg(): Definition and Usage
Avg()
is particularly useful for getting a sense of the central tendency of your data. It ignores any NULL
values encountered in the input data.
Syntax
Syntax
Avg(expression)
Parameter Values
Parameter | Description |
---|---|
expression |
A numeric field or a formula that results in a numeric value. This is required. |
Examples
Calculating the Average Price
This example calculates the average price of products in the 'Products' table.
Syntax
SELECT Avg(Price) AS AveragePrice FROM Products;
Output
The query returns a single value: the average of the 'Price' column.
AveragePrice
------------
18.29
Selecting Products Above Average Price
This example shows how to use the average price calculated with Avg()
in a WHERE
clause to filter products whose price is above average.
Syntax
SELECT * FROM Products
WHERE Price > (SELECT Avg(Price) FROM Products);
Output
This query returns all rows from the 'Products' table where the 'Price' is greater than the average price.
ProductID | ProductName | Price
----------------------------------
1 | Product A | 20.00
2 | Product B | 25.00