Your SQL University
Home » Interview Q & A » Q17. What is the difference between COUNT(*) and COUNT(Column Name)?
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)).
Tags: COUNT, COUNT(*) vs COUNT(ColumnName), COUNT(ColumnName)
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.
Fill in your details below or click an icon to log in:
You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
Connecting to %s
Notify me of new comments via email.
Please visit SQLVERSITY.COM for more details.
Create a free website or blog at WordPress.com.