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.
SELECT AVG(DaysInHospital) AS [AverageStay]
FROM MediCarePatients
WHERE age > 65
AverageStay
71
(1 row(s) affected)
This code finds the average hospital stay of those MediCare patients over the age of 65.