to simplify, I will use a simple table attribute (which means the table is larger) to demonstrate the problem:
I have the following table test:
id | nbr
----+-----
1 | 0
2 |
3 |
4 | 1
5 | 1
(5 rows)
id and nbr are numeric values
Next request
select nbr, count(nbr) from test group by nbr;
outputs:
nbr | count
-----+-------
| 0
1 | 2
0 | 1
(3 rows)
whereas the request is:
select nbr, count(*) from test group by nbr;
outputs:
nbr | count
-----+------
| 2
1 | 2
0 | 1
(3 rows)
It’s hard for me to explain the difference between count (nbr) and count (*) with respect to zero values, can someone explain this to me as if I’m five, thanks
source
share