-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Order BY not working inside Subqueries in Oracle
PostPosted: Thu Jul 05, 2007 1:08 pm 
Newbie

Joined: Mon Aug 07, 2006 2:08 am
Posts: 5
Hi Friends,

Here the description of the problem I'm facing:

I have two tables Person and Department. A person can have lof of departments. I'm trying to run the following sql:


SELECT aa.PERSON_ID FROM PERSON aa WHERE aa.PERSON_ID IN
(
SELECT a.PERSON_ID FROM PERSON a, DEPARTMENT b
WHERE a.DEPT_ID = b.DEPT_ID
ORDER BY b.DEPT_NAME
)

The above mentioned query is not executing in Oracle. Is there any constraint with ORDER BY inside sub queries?

It would be really helpful if anyone could figure this out.

Thanks,
Yogi..


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 06, 2007 3:31 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
>> Is there any constraint with ORDER BY inside sub queries?
Yes.
For instance, You cannot specify an order_by_clause in the subquery of set operators.
But, I don't remember having read something similar for the membership_condition. (ie IN / NOT IN )

>> The above mentioned query is not executing in Oracle.
Understandable.
We don't get anything by ordering the set used with IN.
i) id in (2,4,5)
ii) id in (4,5,2)
both are functionally equivalent.
May be, for this reason, order_by_clause is not allowed here.

-----------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.