C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

Count(*) and Count(ColumnName)


Posted Date: 31 Aug 2007      Posted By: Trilochan Nayak      Member Level: Bronze     Points: 2   Responses: 3



What is the difference between Count(*) and Count(ColumnName)




Responses

Author: Ashutosh    31 Aug 2007Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi
COUNT(ColumnName)==> Returns the count of rows in a table by eliminating NULL values;

COUNT(*) ==>returns the cardinality (total number of rows) for an entire table.

The fact that COUNT(*) and COUNT(column) treat NULLs differently can be used to your advantage in many situations such as calculating the NULLRows

Hope this gives you differece.
- Regards
Ashutosh



Author: Bindu Rajkumar     31 Aug 2007Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

Let b_table having one column name

the following is result of select * from b_table
name
----------
raja
bindu
Null
kumar

1.select count(*) from b_table

result is
4

2. select count(name) from b_table

result is
3

here the thing is in second query the null value is not taken. in the 1 query all rows will returns no matter which value it may contains whether null or any value



Author: sriram    10 Sep 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

select count(*) from emp- it will count null values also
select count(empid) from emp it wont count null values



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : why we using xquery in sql server 2005
Previous : Count
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use