Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project










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 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information