Re: How to identify a column in order by clause

From: Mikito Harakiri <mikharakiri_at_iahu.com>
Date: Fri, 7 Jan 2005 09:33:29 -0800
Message-ID: <mVzDd.26$Df7.106_at_news.oracle.com>


"DA Morgan" <damorgan_at_x.washington.edu> wrote in message news:41debf85$1_1_at_127.0.0.1...
> Mikito Harakiri wrote:
> > The positional notation is misborn ANSI SQL invention. Why is that
> >
> > select table_name, column_name AS COLNAME
> > from user_tab_columns
> > where table_name = 'SERVERS'
> > ORDER BY 2
> >
> > is different from
> >
> > select table_name, column_name AS COLNAME
> > from user_tab_columns
> > where table_name = 'SERVERS'
> > ORDER BY 1+1
>
> 1. The first makes sense

What is so special about "order by" clause to warrant positional notation? Why positional notation isn't used anywhere else?

The theory (the Alice book) says that positional and named perspective are equivalent. One or the other can be used. However, the hypothetical use of positional notation is severely handicapped in SQL since arbitrary expressions involving integer scalars should be distingushed from columns.

> 2. The first doesn't require use of a math routine to perform the addition

You sound like math challenged folks here.

> 3. The first is standard Oracle syntax

I'm sorry, but oracle is not a gospel.

> 4. The second is no different from: ORDER BY 4*0.5: Functional but
> without purpose.

So, ORDER BY SAL+COMM is without purpose as well? How about

ORDER BY SAL+2*COMM - 1 What is "1" in the last expression? Received on Fri Jan 07 2005 - 18:33:29 CET

Original text of this message