can anyone please let me know difference between count(*), count(1), count(0), count('FAST')

marked as duplicate by Paul White Jul 4 at 13:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



enter image description here

If you specify expr, then COUNT returns the number of rows where expr is not null. You can count either all rows, or only distinct values of expr.

If you specify the asterisk (*), then this function returns all rows, including duplicates and nulls. COUNT never returns null.

0, 1, 'FAST' are all constant expressions, they are never null, so the query returns all rows.

* also returns all rows by definition.

So they all do the same.

Not the answer you're looking for? Browse other questions tagged or ask your own question.