Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: And the correct answer is?

Re: And the correct answer is?

From: Mikito Harakiri <mikharakiri_at_ywho.com>
Date: Thu, 3 Apr 2003 15:22:20 -0800
Message-ID: <Hs3ja.9$UE2.135@news.oracle.com>


"sfk" <nospan_at_noway.org> wrote in message news:3E8E0B9E.B0B9251F_at_noway.org...
> SELECT empno, ename FROM emp ORDER BY 1;

I would object that interpreting 1 in the above query as column#1 is a good idea in the first place. Indeed, "order by" clause allows arbitrary expression wtich can involve any function upon columns, for example

SELECT empno, ename FROM emp ORDER BY lower(empno) || ename

"1" is just a constant function (or constant expression), so that

SELECT empno, ename FROM emp ORDER BY 1

must be equivalent to

SELECT empno, ename FROM emp ORDER BY 2

and to just

SELECT empno, ename FROM emp

If you are still not convinced, what in your opinion should

select * from emp order by 2 || 3

return? Received on Thu Apr 03 2003 - 17:22:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US