Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Calculates the arithmetic mean of a set of values contained in a specified field on a query.

Syntax

Avg ( expr )

The expr placeholder represents a string expression identifying the field that contains the numeric data you want to average or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The average calculated by Avg is the arithmetic mean (the sum of the values divided by the number of values). You could use Avg, for example, to calculate average freight cost.

The Avg function does not include any Null fields in the calculation.

You can use Avg in a query expression and in the SQL property of a QueryDef object or when creating a recordset object based on an SQL query.

Examples

Expression

Results

SELECT Avg([UnitPrice]) AS Expr1 FROM ProductSales;

Returns the average of all the values in the field "UnitPrice" from the table "ProductSales" and displays in column Expr1.

SELECT Avg([SalePrice]) AS AvgSalePrice, Avg([Discount]) AS AvgDiscount FROM ProductSales;

Returns the average "SalePrice" and "Discount" field from the table ProductSales. The results are displayed in the column "AvgSalePrice" and "AvgDiscount" respectively returns the average of all "SalePrice" where the "Quantity" sold is over 10. The results are displayed in the column "AvgSalePrice".

SELECT Abs(Avg([Discount])) AS AbsAverageDiscount FROM ProductSales;

Returns the absolute value of the average value of "Discount" field and displays in the column "AbsAverageDiscount".

Calculating Fields in SQL Functions

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×