Re: Reuse previously calculated column in sql query?

From: Rod Taylor <pg(at)rbt(dot)ca>
To: Philippe Lang <philippe(dot)lang(at)attiksystem(dot)ch>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Reuse previously calculated column in sql query?
Date: 2004-10-20 13:05:38
Message-ID: 1098277537.747.91.camel@home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 2004-10-20 at 08:50, Philippe Lang wrote:
> Hello,
>
> Is it possible to reuse a previously calculated column in a following
> column, like:

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Weiping 2004-10-20 14:57:34 Re: the problem of createlang!
Previous Message Philippe Lang 2004-10-20 12:50:11 Reuse previously calculated column in sql query?