COUNT is an aggregate function used to count rows or non-NULL values in a result set.
Counting records is one of the most common analytical requirements, from customer counts to transaction volumes.
Count the total number of employees.
SELECT
COUNT(*) AS TotalEmployees
FROM Employees;
COUNT is used for customer counts, transaction volumes, employee headcount, order analysis, and operational reporting.
- COUNT is an aggregate function.
- COUNT(*) counts rows.
- COUNT(column) counts non-NULL values.
- COUNT can be combined with GROUP BY.
- COUNT is widely used in data analysis.
What does COUNT(*) do?
COUNT(*) counts the number of rows returned by the query.
Does COUNT(column) count NULL values?
No. COUNT(column) counts only non-NULL values in that column.