COUNT(*) counts rows.
COUNT(*)
counts every row, including rows containing NULL values.
COUNT(column) counts only non-NULL values in that column.
Suppose:
id | name 1 | Raja 2 | NULL 3 | Arun
Then:
COUNT(*) = 3 COUNT(name) = 2
SQL · Aggregations & Grouping
What is the difference between COUNT(*) and COUNT(column)?
COUNT(*) counts rows.
COUNT(*)
counts every row, including rows containing NULL values.
COUNT(column) counts only non-NULL values in that column.
Suppose:
id | name 1 | Raja 2 | NULL 3 | Arun
Then:
COUNT(*) = 3 COUNT(name) = 2
🎯 Put this concept into practice
Solidify this answer with real hands-on interview drills in the browser studio.