Home > Code > SQL Server > COUNT() function in SQL Server

COUNT() function in SQL Server

by Narain Siddharth   on Jun 01, 2011   Category: SQL Server   |  Views: 1279    |  Points: 25   |  Silver 


The COUNT () function in sql server is used to returns the no of rows in a specific table with matches the specific condition.

Select COUNT (EMP_NAME) from employee

The above query will returns the total no of rows of the specific column and this query does not count the NULL values.

Select COUNT(*) from employee

The above query will returns the total no of records in the specific table, it counts all records with null values.
We can use DISTINCT function in the COUNT function like as shown below

Select COUNT(DISTINCT EMP_LOCATION) from employee





Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts