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

Count

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.

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)

Tags:
Latest Comments
  1. Suresh Kumar patra

    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

Your email address will not be published. Required fields are marked *