Sobes.tech
Senior

COUNT(*) vs COUNT(column) — will the result be the same or different?

sobes.tech AI

Answer from AI

COUNT(*) counts the total number of rows in a table, including those where column values may be NULL.

COUNT(column) counts the number of rows where the value in the specified column is not NULL.

Example:

id value
1 10
2 NULL
3 20
  • COUNT(*) will return 3
  • COUNT(value) will return 2

Thus, the result will differ if there are NULL values in the column.

COUNT(*) vs COUNT(column) — will the result be the… - sobes.tech