niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
ORDER BY With Set Operators
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
dd
*nix forums beginner


Joined: 08 Jun 2005
Posts: 14

PostPosted: Mon Feb 28, 2005 11:24 am    Post subject: Re: ORDER BY With Set Operators Reply with quote

typos:
2. if there is only 1 SET operator, we can use names instead of position so
long as the number and type of the 2 select list columns are matching:
select col1, col2,col3 from a UNION ALL
select a,b,c from b
order by col1

"dd" <dd@dd.com> ¦b¶l¥ó news:42230cad$1_1@rain.i-cable.com ¤¤¼¶¼g...
Quote:
In 9iR2, when we use ORDER BY with SET operators(UNION/UNION
ALL/INTERSECT/MINUS), the naming rules is very confusing and appreciate if
anyone can clarify:

According to SQL Reference:
------------------------------------
1. Must use position notation i.e. ORDER BY 1. We cannot use 'ORDER BY
colname'.

By personal testing with 9iR2:
------------------------------------
1. If there is >=2 SET operators, the above rule is true e.g.
select col1,col2,col3 from a UNION ALL
select a,b,c from b MINUS
select i,j,k from c
order by 1

and 'order by colname' => error

2. if there is only 1 SET operator, we can use names instead of position
so
long as the number and type of the 2 select list columns are matching:
select col1, col2 from a UNION ALL
select a,b,c from b
order by col1 okay

So, why the difference? Which rule should we follow?

Back to top
dd
*nix forums beginner


Joined: 08 Jun 2005
Posts: 14

PostPosted: Mon Feb 28, 2005 11:18 am    Post subject: ORDER BY With Set Operators Reply with quote

In 9iR2, when we use ORDER BY with SET operators(UNION/UNION
ALL/INTERSECT/MINUS), the naming rules is very confusing and appreciate if
anyone can clarify:

According to SQL Reference:
------------------------------------
1. Must use position notation i.e. ORDER BY 1. We cannot use 'ORDER BY
colname'.

By personal testing with 9iR2:
------------------------------------
1. If there is >=2 SET operators, the above rule is true e.g.
select col1,col2,col3 from a UNION ALL
select a,b,c from b MINUS
select i,j,k from c
order by 1

and 'order by colname' => error

2. if there is only 1 SET operator, we can use names instead of position so
long as the number and type of the 2 select list columns are matching:
select col1, col2 from a UNION ALL
select a,b,c from b
order by col1 okay

So, why the difference? Which rule should we follow?
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 5:58 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts "ORDER BY" question Mr.Kane Oracle 3 Wed Jul 19, 2006 10:53 pm
No new posts mysql order question OKAN ARI MySQL 1 Wed Jul 19, 2006 7:03 pm
No new posts Constraint for two fields unique any order MargaretGillon@chromalloy PostgreSQL 5 Wed Jul 19, 2006 4:01 pm
No new posts Bug#378288: ITP: poa -- Partial Order Alignment for multi... Charles Plessy devel 0 Sat Jul 15, 2006 2:50 am
No new posts cursor traverse order of hash based database sub.apache@gmail.com Berkeley DB 0 Tue Jul 11, 2006 12:32 am

Debt Consolidation | Bad Credit Mortgages | Internet Advertising | Debt Consolidation | Debt Consolidation
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1285s ][ Queries: 20 (0.0594s) ][ GZIP on - Debug on ]