Re: Referncing a calculated column in a select?

Поиск
Список
Период
Сортировка
От Ron
Тема Re: Referncing a calculated column in a select?
Дата
Msg-id 9a55a78e-6a9d-b8a0-d9c8-f5a6fbc6fcea@gmail.com
обсуждение исходный текст
Ответ на Referncing a calculated column in a select?  (stan <stanb@panix.com>)
Ответы Re: Referncing a calculated column in a select?
Список pgsql-general
On 9/12/19 2:23 PM, stan wrote:
> I am creating some views, that have columns with fairly complex calculations
> in them. The I want to do further calculations using the result of this
> calculation. Right now, I am just duplicating the first calculation in the
> select fro the 2nd calculated column. There must be a batter way to do
> this, right?

I must be misunderstanding you, because you can just do more of what you're 
doing now.

Here's an example of doing some calculations in the creation of the view, 
and then more calculations when selecting from the view:

test=# create table gargle (i integer, j integer);
CREATE TABLE

test=# create view v_gargle (i1, j1) as select i*2, j*3 from gargle;
CREATE VIEW

test=# select * from v_gargle;
  i1 | j1
----+----
   4 |  9
(1 row)

test=# select i1 - 3, j1 * 8 from v_gargle;
  ?column? | ?column?
----------+----------
         1 |       72




-- 
Angular momentum makes the world go 'round.



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

Предыдущее
От: Aaron Spike
Дата:
Сообщение: Re: Recover data from aborted transactions
Следующее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Referncing a calculated column in a select?