Home » SQL & PL/SQL » SQL & PL/SQL » Simple SQL Question (Oracle 9i on Windows 2003 Server)
Simple SQL Question [message #284092] Wed, 28 November 2007 16:38 Go to next message
arvindram
Messages: 2
Registered: November 2007
Junior Member
The below query works:

select (select 1 from dual where t.mydummy = t.mydummy)
from
( select dummy mydummy from dual
) t
group by t.mydummy

But the below one does not:

select (select 1 from dual where t.mydummy = t.mydummy)
from
(
select decode(dummy, dummy, dummy, 'XYZ') mydummy from dual
) t
group by t.mydummy

Can anyone explain why?


Thanks,

Aravind
Re: Simple SQL Question [message #284118 is a reply to message #284092] Wed, 28 November 2007 23:42 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Because In first Query ,
mydummy regeres a field while
In second query referes an expresssion

So You need to group by mydummy in the second query.

Somethig like ,

select MAX((select 1 from dual where t.mydummy = t.mydummy))
from 
(
select decode(dummy, dummy, dummy, 'XYZ') mydummy from dual
) t
group by t.mydummy


Thumbs Up
Rajuvan.
Re: Simple SQL Question [message #284313 is a reply to message #284118] Thu, 29 November 2007 06:23 Go to previous message
arvindram
Messages: 2
Registered: November 2007
Junior Member
Thanks for the explanation. Now it makes sense.
Previous Topic: PIVOT QUERY NOT WORKING PLEASE HELP
Next Topic: removing a column
Goto Forum:
  


Current Time: Thu Dec 08 14:35:57 CST 2016

Total time taken to generate the page: 0.05156 seconds