JetSQL » Functions » COUNT

Syntax:
SELECT COUNT ( field ) AS [ expression ]
FROM table
[ WHERE criteria ]
[ GROUP BY grouping_expression ]
[ HAVING criteria ]
field
The name of the column on which the values are to be counted.
expression
The name to be displayed for the resulting count.
table
The name of the table the information is being retrieved from.
criteria
The condition(s) that dictate which rows are to be counted.
grouping_expression
An optional parameter that specifies a set of columns on which to group matching data.

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.

Examples

Code:
SELECT COUNT(Patients) AS [PatientCount]
FROM MediCarePatients
WHERE Date = #06/26/2000#
Output:
PatientCount
34

(1 row(s) affected)
Explanation:

This code finds the number of MediCare patients that were in the hospital on June 26, 2000 and stores that number into 'PatientCount'.

Note: The date format in Jet SQL is: #mm/dd/yyyy#.

Language(s): MS SQL Server

See Also: