Subject Re: [firebird-support] Re: order by column alias problem
Author Ann W. Harrison
At 12:20 AM 12/20/2004, Helen Borrie wrote:

> From a logical POV, it doesn't make sense to derive a field just for the
>purpose of changing its name, since it detaches the output column from the
>originating column and precludes the use of an index to speed the sorting.

Actually, we ought to be able to map from the alias
to the field without a great deal of difficulty.


>There are indications that the standard will deprecate the "by degree"
>option in future...not sure why...maybe Arno or Ann can answer.

I just had a look at the new standard. It defines the
ORDER BY clause as ORDER BY <sort specification list>
which, in turn, is defined like this:

<sort specification list> ::=
<sort specification> [ { <comma> <sort specification> }... ]

<sort specification> ::=
<sort key> [ <ordering specification> ] [ <null ordering> ]

<sort key> ::= <value expression>

<ordering specification> ::=
ASC | DESC

<null ordering> ::=
NULLS FIRST | NULLS LAST


Scary? A sort key is just a value expression, which can be anything.
I haven't seen any reference to the value expression 1 mapping to the
first item in the select list, so it may already be deprecated and
redefined. (They can't do that! or did they? Or both!?)

However, it certainly appears to be the case that you could sort by
an alias. We just need to keep a bit more context (gag) in the
compiler.

Regards,


Ann