Re: alias question

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: alias question
Дата
Msg-id 20011214063137.K11758-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на alias question  (Ceasar <ocerda@hotmail.com>)
Ответы Re: alias question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Thu, 13 Dec 2001, Ceasar wrote:

> I was wondering if you could use an alias to do math calculations:  for
> example,
>
> select Bank1,
> (var1 + var2) as calc,
> calc*100 as var2
>
> From......
>
> I keep getting this message that says that calc is not in any of the
> tables in the From statement. Is it possible to use a alias (calc) to
> make further calculations?  If so, how?  Any help would be greatly
> appreciated.

I don't believe directly.  You can fake this somewhat by making a two
level query where the calculation is done in a subselect in from. It
looks however like the above is recursive, var2 depends on calc and calc
depends on var2 (or is var2 also a column name?)
Assuming it is a column, you should be able to do something like

select Bank1, calc, calc*100 as var2 from
 (select bank1, (var1+var2) as calc from ... ) ali;



В списке pgsql-general по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Insert character codes in PosgreSQL with SQL command
Следующее
От: Francisco Reyes
Дата:
Сообщение: Re: User rights across databases