Solve “Coalesce null salaries to zero”

Free. Runs in your browser, no install.

SQL · Aggregations & Grouping

COUNT(*) vs COUNT(column)

Mediumcountnullaggregation

Interview question

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

How to answer

The short answer

COUNT(*) counts rows.

SQL
COUNT(*)

counts every row, including rows containing .

COUNT(column) counts only non-NULL values in that column.

Suppose:

idname
1Raja
2NULL
3Arun

Then:

Output
COUNT(*)       = 3
COUNT(name)    = 2

Lock it in with a real drill

You remember an answer longer once you have used it. Try a hands-on problem on this concept.

Open related drill