Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. COUNT(*) vs COUNT(column)

SQL · Aggregations & Grouping

COUNT(*) vs COUNT(column)

Mediumsql-11
countnullaggregation

Question

What is the difference between COUNT(*) and COUNT(column)?

Solution

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.

Open related drill →
PreviousNext