The short answer
COUNT(*) counts rows.
COUNT(*)counts every row, including rows containing .
COUNT(column) counts only non-NULL values in that column.
Suppose:
| id | name |
|---|---|
| 1 | Raja |
| 2 | NULL |
| 3 | Arun |
Then:
COUNT(*) = 3
COUNT(name) = 2Free. Runs in your browser, no install.
SQL · Aggregations & Grouping
What is the difference between COUNT(*) and COUNT(column)?
The short answer
COUNT(*) counts rows.
COUNT(*)counts every row, including rows containing .
COUNT(column) counts only non-NULL values in that column.
Suppose:
| id | name |
|---|---|
| 1 | Raja |
| 2 | NULL |
| 3 | Arun |
Then:
COUNT(*) = 3
COUNT(name) = 2Lock it in with a real drill
You remember an answer longer once you have used it. Try a hands-on problem on this concept.