Subject | Re: [firebird-support] Use of column aliases in a SELECT |
---|---|
Author | Jaison |
Post date | 2012-01-27T11:08:42Z |
Hi,
On 27/1/2012 4:16 PM, Josef Kokeš wrote:
> 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
Regards,
Jaison Joseph