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.