| Count(1) and count(*) [message #532677] |
Thu, 24 November 2011 00:27  |
sb0024297
Messages: 46 Registered: June 2010
|
Member |
|
|
Hi,
can you tell me the difference between count(1) and count(*). As i know count(*) will give number of rows irrespective of null and count(1) will not count the null.
But i am confuse by the below result. My Oracle version is 10 g.
SQL> select * from t1;
A B C
---------- -------------------- --------------------
1 2 3
2
5
SQL> select rownum,a.* from t1 a;
ROWNUM A B C
---------- ---------- -------------------- --------------------
1 1 2 3
2 2
3 5
4
SQL> select count(1) from t1;
COUNT(1)
----------
4
SQL> select count(*) from t1;
COUNT(*)
----------
4
SQL> select rownum,a.* from test1 a;
ROWNUM COL
---------- ----------
1 1
2 2
3 3
4
5 4
SQL> select count(1) from test1;
COUNT(1)
----------
5
SQL> select count(*) from test1;
COUNT(*)
----------
5
|
|
|
|
| Re: Count(1) and count(*) [message #532680 is a reply to message #532677] |
Thu, 24 November 2011 00:55   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
|
The number of times that this question has been asked on the internet can be counted in the thousands (at least!) Do a google search on count(*) v count(1). In fact, just use the orafaq search facility, it's been asked here many many times too. There are many, many answers out there. If you find conflicts and are still confused, come back and ask for clarification.
|
|
|
|
|
|
|
|