Reuse previously calculated column in sql query? - Mailing list pgsql-sql

From Philippe Lang
Subject Reuse previously calculated column in sql query?
Date
Msg-id 6C0CF58A187DA5479245E0830AF84F42080442@poweredge.attiksystem.ch
Whole thread Raw
Responses Re: Reuse previously calculated column in sql query?
List pgsql-sql
Hello,

Is it possible to reuse a previously calculated column in a following
column, like:

SELECT
foo.val1 AS col1,
long_calculation(foo.val1) AS col2,
COL2 * 0.75 AS col3
FROM foo;

instead of writing:

SELECT
foo.val1 AS col1,
long_calculation(foo.val1) AS col2,
long_calculation(foo.val1) * 0.75 AS col3
FROM foo;


Philippe


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: SQL update function faililed in Webmin Interface
Next
From: Rod Taylor
Date:
Subject: Re: Reuse previously calculated column in sql query?