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
All Functions
WHERE Clause
HAVING Clause
GROUP BY Clause
FUNCTION: SUM
SELECT SUM(field) AS [expression]
FROM table
[WHERE ...]
[GROUPBY ...]
[HAVING ...]
The
SUM
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:
AVG, COUNT, MAX, MIN, STDEV, STDEVP, VAR, VARP
. Note that all of these functions return a single value.
The
SUM
function simply adds all of the values in a field and return the total sum.
This code finds the total number of days that MediCare patients stayed in the hospital and stores that information in MCTotalDays.
SELECT SUM(DaysInHospital) AS [MCTotalDays]
FROM MediCarePatients
WHERE age > 65
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information