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.
SELECT COUNT(Patients) AS PatientCount
FROM MediCarePatients
WHERE Date = '06/26/2000';
PatientCount
34
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 SQL is: 'mm/dd/yyyy'.
Language(s):
MS SQL Server
See Also: