FUNCTION: AVG
SELECT AVG(field) AS [expression]
FROM table
[WHERE ...]
The AVG function is one of the aggregate functions
that are used to calculate statistical information
for a specified numeric field in a query.
The other aggregate functions are: COUNT, MAX, MIN, STDEV, STDEVP,
SUM, VAR, VARP.
Note that all of these functions return a single value.
The AVG function simply calculates the arithmetic mean
(i.e., the sum of the values divided by the number of values).
Values which are NULL are not included in the calculations.
If the field is just an empty set, no average will be calculated.
This code finds the average hospital stay of those MediCare patients
over the age of 65:
SELECT AVG(DaysInHospital) AS [AverageStay]
FROM MediCarePatients
WHERE age > 65
Copyright 2000 by Infinite Software Solutions, Inc.
Trademark Information
|