Home » Interview Q & A » Q17. What is the difference between COUNT(*) and COUNT(Column Name)?

Q17. What is the difference between COUNT(*) and COUNT(Column Name)?

Our Categories

Blog Stats

  • 32,852 hits

Calendar

June 2013
M T W T F S S
« May    
 12
3456789
10111213141516
17181920212223
24252627282930

Please visit SQLVERSITY.COM for more details.

COUNT(*) – Returns the total number of records in a table (Including NULL valued records).

COUNT(Column Name) Returns the total number of Non-NULL records. It means that, it ignores counting NULL valued records in that particular column.

Please find the below Example:

In the below screenshot, LastName of EmployeeID 3 is NULL. So It will not be counted when we are counting records on the basis of LastName (i.e. COUNT(LastName)).

Count() VS COUNT(ColumnName)

Advertisements

1 Comment

  1. Suresh Kumar patra says:

    count(*)- Return the number of rows in a table that satisfy the criteria of the select statement.

    count- Return the number of non-null values in the column identified by exper.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: