COUNT(*) counts all rows, including rows containing NULL values. COUNT(column_name) counts only non-NULL values in the specified column.
Knowing how COUNT handles NULL values prevents incorrect reporting and helps analysts measure both total records and available values.
If a table contains 100 employees but 10 employees have no email address, COUNT(*) returns 100 while COUNT(Email) returns 90.
SELECT
COUNT(*) AS TotalEmployees,
COUNT(Email) AS EmployeesWithEmail
FROM Employees;
This is useful for data completeness analysis, customer contact validation, employee records, and data-quality reporting.
- COUNT(*) counts every row.
- COUNT(column) ignores NULL values.
- COUNT(*) and COUNT(column) can return different results.
- This behavior is important for data-quality analysis.
- COUNT can measure data completeness.
Does COUNT(*) count rows containing NULL?
Yes. COUNT(*) counts every row regardless of NULL values.
Does COUNT(column) count NULL values?
No. COUNT(column) counts only non-NULL values.