Home » SQL & PL/SQL » SQL & PL/SQL » group by clause
group by clause [message #256197] Fri, 03 August 2007 07:04 Go to next message
durai
Messages: 38
Registered: December 2006
Member
Step :1
----------
SQL> select * from abcd;

A B
---------- ----------------------
-10 aaa
100 aaa
-50 bbb
40 ccc
20 ccc

Step :2
----------
SQL> select count(b) from abcd where b ='ZZZ';

COUNT(B)
----------
0

Step :3
----------
SQL> select count(b) from abcd where b ='ZZZ' group by b;

no rows selected

comparing step 2 and step 3, i used group by in step 3( that's reason may be i couldn't get the value 0) but
why what's the reason of this but i am able to get the result through step 4.

Step :4
----------
SQL> select count(*) from (select count(b) from abcd where b ='ZZZ' group by b);

COUNT(*)
----------
0


thanx in advance
Re: group by clause [message #256204 is a reply to message #256197] Fri, 03 August 2007 07:25 Go to previous messageGo to next message
Frank Naude
Messages: 4502
Registered: April 1998
Senior Member
It's because step 3 can return multiple rows. No grouping is found, so it returns "no rows selected".
Re: group by clause [message #256218 is a reply to message #256197] Fri, 03 August 2007 07:56 Go to previous messageGo to next message
sispk6
Messages: 164
Registered: November 2006
Location: pakistan
Senior Member
query is not returning any value;
thats why no rows found
Re: group by clause [message #256224 is a reply to message #256218] Fri, 03 August 2007 08:13 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Do please read the question more carefully.

Step 2 in the query is based on the same data set and does return a row.
Previous Topic: UPDATE with Order By
Next Topic: Selecting details from the 3 most recent rows
Goto Forum:
  


Current Time: Sun Dec 11 08:29:46 CST 2016

Total time taken to generate the page: 0.07659 seconds