Subject Re: [ib-support] Expressions/UDFs and Order By
Author IB/FB List
Hi Kevin,

Could you use a view to encapsulate the original query ?

This way you could sort by the name of the views column, but if your Select
statment are dinamically created (with diferent structure each time) then
this is not an option.

If you create the select statment on the fly, you could generate the order
column index on the fly too.

HTH

see you !

Alexandre Benson Smith
Development
THOR Software
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br

At 02:52 31/10/2002 +0000, you wrote:
>Hello all,
>
>I'm pretty sure I know the answer to my question, but I want to make
>sure.
>
>I have a SELECT statement as follows:
>
>SELECT col1, col2,...coln,BIN_OR(col4,324232)*(long math expression)
>math_result ORDER BY math_result;
>
>Now, as most of you probably know this query will fail because
>the 'math result' alias is illegal in the ORDER BY clause. Instead
>one must, find its ordinal position in the column list and use that
>in the ORDER BY clause.
>
>For example,
>
>SELECT col1, col2,BIN_OR(col4,324232)*(long math expression)
>math_result ORDER BY 3
>
>I know this is no big deal, because one can easily keep track of the
>position of the desired expression in the column list, but in my
>case where the number of columns in the selects is constantly
>changing it's a pain. Is there a way to specify an alias instead of
>an ordinal?
>
>If not, is there a forum in which I can appeal to the firebird
>developers to include this capability?
>
>Thanks,
> Kevin Morris
>
>
>
>To unsubscribe from this group, send an email to:
>ib-support-unsubscribe@egroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/