Reuse previously calculated column in sql query?

From: "Philippe Lang" <philippe(dot)lang(at)attiksystem(dot)ch>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Reuse previously calculated column in sql query?
Date: 2004-10-20 12:50:11
Message-ID: 6C0CF58A187DA5479245E0830AF84F42080442@poweredge.attiksystem.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rod Taylor 2004-10-20 13:05:38 Re: Reuse previously calculated column in sql query?
Previous Message Scott Marlowe 2004-10-20 07:49:09 Re: SQL update function faililed in Webmin Interface