Subject SQL Expressions
Author Ian A. Newby
Hi All,
In other SQL databases, the expression

select col1 * 10 as a, col2 + 5 as b, a + b as c from mytable order
by c, b, a

is allowed.

How difficult would it be to allow this type of sql statement to be
accepted? I belive it splits into two problems:

1. Ordering by calculated column names (not ordinal position).
2. Allow calculated column names to be used in further calculated
columns.

Just out of interest, what does FB do when the above SQL is written as

select col1 * 10 as a, col2 + 5 as b, ((col1 * 10) + (col2 + 5)) as c
from mytable order by 3, 2, 1?

Does it read col1 and col2 multiple times from the database (not a
problem with this example but when they are subqueries it could be).

Regards Ian Newby