Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group