Re: Inconsequences in SELECT/ORDER BY
Posted in 1994
Topics: Stored Procedures & SPL
In article 3r4@maicgn.SoftwareEngineering, ar@mai.de (Achim Reiners) writes:
>I had a little problem with an ORDER BY clause:
>
>First of all I use the possibility to SELECT a column more than once
>in a SELECT-statement:
>
>SELECT col_a, col_b, col_a FROM tab;>
>This works fine and makes life easier for me (really!).
>
>Now I tried: SELECT col_a, col_b, col_a FROM tab ORDER BY col_a;
>
>I received the "ambiguous column" - error. I think that in this context
>this error should NOT be reported.
Sure it should. Compilers and interpreters don't have enough AI in them
to guess at what you mean. If you said "ORDER BY col_a, col_b", there'd be
a big difference in the way the columns were sorted. Are you expecting, then,
that "ORDER BY col_a" should be handled differently? I certainly don't think
it should, hence the error message.
>
>O.K. the workaround is quite easy using "display labels".
>( SELECT col_a ca1, col_b, col_a ca2 FROM tab ORDER BY ca1; )
>
>What is the opinion of the net? Is the error reporting correct or not?
>
I wouldn't want it any other way.
As a side issue...
I can't help but wonder why on earth selecting the same column twice
makes things easier. I would think that if you're trying to assign
the same value to 2 different variables, you'd simply assign the second
after the select.
---
===============================================================================
Joe Hartley | jh@cadre.com - Whenever you find that you are on the
Cadre Technologies | side of the majority, it is time to reform. - M. Twain
222 Richmond St. | --------------------------------------------------------
Providence, RI 02903 | Overman 1st Class - the Kilgore Trout Memorial Clench
(401) 351-5950 x266 | of the Church of the SubGenius
===============================================================================