All Functions
WHERE Clause
HAVING Clause
GROUP BY Clause
FUNCTION: COUNT
SELECT COUNT(field) AS [expression]
FROM table
[WHERE ...]
[GROUPBY ...]
[HAVING ...]
The
COUNT
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, MAX, MIN, STDEV, STDEVP, SUM, VAR, VARP
. Note that all of these functions return a single value.
The
COUNT
function simply counts how many values are in a field. Values which are
NULL
are included in the counting. If the field is just an empty set,
COUNT
returns zero.
This code finds the number of MediCare patients that were in the hospital on June 30, 1999 and stores that number into PatientCount. Note that the date format in Jet SQL is: #mm/dd/yyyy#
SELECT COUNT(Patients) AS [PatientCount]
FROM MediCarePatients
WHERE Date = #06/26/2000#
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information