What is Count (column name) and count(*) SELECT COUNT(*) in sql server [Resolved]

Posted by Jitendrasoft09 under Sql Server on 6/26/2013 | Points: 10 | Views : 16659 | Status : [Member] [MVP] | Replies : 2
Hi All,
I want to understand What is Count (column name) and count(*) in sql server, let me know if anybody knows.
Example

Select count(Empname) from Employee;
Select count(*) from Employee.

Jitendra Kumar
If my post helps you, plz mark as an answer.



Responses

Posted by: Neeraaj.Sharma on: 6/27/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Mark as answer if you are satisfy with it

Count (*) returns numbers of rows with in the table And
Count (Column_name) returns numbers of rows which contain the that particular column .
i mean not null data in that column:
EXAMPLE BELOW


Create Table #count (ID int identity , name varchar (10))


INsert into #count
Select 'A' union all
Select 'B' Union all
Select null

Select count(*) From #count

Select count(name) From #count



Visit my blog www.tutorialsqlserver.com

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jitendrasoft09 on: 6/27/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
nice explanation Neeraj....

Jitendra Kumar
If my post helps you, plz mark as an answer.

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response