Re: Repeated columns in an ORDER BY clause?

From: Keith W. Hare <keith_at_jcc.com>
Date: 1996/05/08
Message-ID: <Dr32uE.FHB_at_jcc.com>#1/1


gautam_at_gautam.engr.sgi.com (Gautam Bhargava) wrote:
>Is it legal to repeat column names in an ORDER BY cluase. In other words,
>is the following a legal SQL query?
>
> SELECT a, b, c FROM myTable
> ORDER BY a, b, a
>
>Sybase 10.0 flags an error on this.
>Oracle 7.2 processes it just fine.
>
>What does the "official" ANSI-standard have to say?
>
>Thanks.
>
>--

Gautam,

I took a look at order by in SQL-92 (ANSI X3.135-1992/ISO 9075:1992). It does not restrict multiple use of a column in an order by. Nor does it require multiple use to be supported.

Since the standard does not say either way, an implementation of SQL could argue that either is correct.

Keith Hare
JCC Consulting, Inc.
Member, ANSI X3H2 -- the US SQL standards committee http://www.jcc.com/sql_stnd Received on Wed May 08 1996 - 00:00:00 CEST

Original text of this message