can anyone please let me know difference between count(*), count(1), count(0), count('FAST')
Asked
Active
Viewed 52 times
0
Kilaru Krishna Chaitanya
- 13
- 1
- 3
1 Answers
4
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.
Balazs Papp
- 41,488
- 2
- 28
- 47
