count function [message #223197] |
Wed, 07 March 2007 23:54 |
subramanian.sp
Messages: 13 Registered: March 2007 Location: Pune
|
Junior Member |
|
|
1) select count(1) from emp where empcode=5454353 group by firstname;
if where condition fails , it goes to no_data_found exception but if i remove the
group by statement the result becomes 0. why ?
2) whats the difference between select count(1) and count(*) ?
|
|
|
|
Re: count function [message #223206 is a reply to message #223197] |
Thu, 08 March 2007 00:27 |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
1) furthermore when you remove the condition you may get more than one row with the group by clause! that's the way GROUP BY clause works. See some examples in documentation.
Check the result of select firstname, count(1) from emp group by firstname;
2) Read about it on AskTom.
|
|
|
Re: count function [message #223253 is a reply to message #223206] |
Thu, 08 March 2007 03:17 |
|
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
reported |
By: subramanian.sp
On: Thu, 08 March 2007 10:06
Reason: select count(*) from tablename will take more time to execute,but if you use select count(1) from tablename , system will take less time. even you can execute like select count(4356435) from tablename. How oracle is taking the argument function in c
| I'm afraid you have a bit of an off day, subramanian.sp, because not only is your reply wrong (count(*) won't take more time than count(1)), you also failed to reply properly. Don't use the "report" link, use the "reply" button instead.
MHE
|
|
|