Subject Re: [firebird-support] Use of column aliases in a SELECT
Author Josef Kokeš
>> Hi!
>>
>> I find myself repeatedly writing code such as
>>
>> SELECT (a+b)*c AS value1,
>> some_function((a+b)*c) AS value2,
>> some_other_function((a+b)*c) AS value 3
>> FROM ...
>>
>> Is there any other way to "reuse" a calculated value by referencing its
>> alias than through views? E.g.
>>
>> CREATE VIEW valueview AS SELECT SELECT (a+b)*c AS value1 FROM ...
>>
>> SELECT value1, some_function(value1) AS value2 ...
>>
>> I know I can reference the column by its position in GROUP BY, but I
>> need to reference it in the field list as well as in the WHERE condition.
>>
>> Thanks,
>>
>> Pepak
> How about derived tables? - (supported from version 2.0 onwards)
>
> http://www.firebirdsql.org/refdocs/langrefupd21-select.html#langrefupd21-derived-tables

I guess. I am just not very familiar with them yet, as I still need to
support Firebird 1.5. But it's definitely something to keep in mind once
I get rid of those.

Thanks,

Pepak