My understanding is:
select a, b from t1
union
select b, a from t1
is equivalent to
select a as a, b as b from t1
union
select b as a, a as b from t1
And therefore, the first sql statement controls the resulting column names,
and the order by applies to the column names (transitively) from the first
statement.
I'll find a reference in SQL89/SQL92 to support my understanding, but this
is how Oracle behaves. :)
--andy
On 4/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Consider this query:
SELECT a, b FROM t1 UNION SELECT b, a FROM t1 ORDER BY a,b;
Is the query above equalent to:
(1) SELECT a, b FROM t1 UNION SELECT b, a FROM t1 ORDER BY 1,2;
Or is it the same as:
(2) SELECT a, b FROM t1 UNION SELECT b, a FROM t1 ORDER BY 2,1;
I need to know this in order to fix ticket #2296. It
might not be obvious why this is important to ticket #2296
but it is, so I would appreciate any help.
--
D. Richard Hipp <[EMAIL PROTECTED]>
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------