The SQL COUNT function returns the number of values of the specified column.
Null values are not counted. This function can also be used to count the number of rows in the table.
Employees Table
employeeID | employeeName | age |
1000 | John Smith | 40 |
1001 | Fred White | 27 |
1002 | Jane Scott | 53 |
1003 | Samuel Williams | 31 |
In this example, we want to count the number of rows in a table.
Syntax
SELECT COUNT(column_name)
FROM Table
Or
SELECT COUNT(*)
FROM Table
|
Example
SELECT COUNT(employeeID) as [Total Count]
FROM employees
Or
SELECT COUNT(*) as [Total Count]
FROM employees
|
Results
The SQL COUNT function is used to count the number of rows in a table. You can also use other key words such as
DISTINCT and WHERE to further filter the data and make the results more specific to the range of data you are looking for.
Please help us spread the word by socializing it today!
Did you find something wrong with the information on this page? Please take a moment to report it to us
so that we can continue to improve the quality of the information on this site. Click here to
report an issue with this page.
Recommended Books & Training Resources