pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <pg@rbt.ca>
To: Philippe Lang <philippe.lang@attiksystem.ch>
Cc: pgsql-sql@postgresql.org
Subject: Re: Reuse previously calculated column in sql query?
Date: Wed, 20 Oct 2004 09:05:38 -0400
Message-ID: <1098277537.747.91.camel@home> (raw)
In-Reply-To: <6C0CF58A187DA5479245E0830AF84F42080442@poweredge.attiksystem.ch>
References: <6C0CF58A187DA5479245E0830AF84F42080442@poweredge.attiksystem.ch>

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;





view thread (3+ messages)  latest in thread

Message-ID: <1098277537.747.91.camel@home>
Permalink:  ../1098277537.747.91.camel@home/
Also on:    postgresql.org/message-id/1098277537.747.91.camel@home

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pg@rbt.ca, philippe.lang@attiksystem.ch
  Subject: Re: Reuse previously calculated column in sql query?
  In-Reply-To: <1098277537.747.91.camel@home>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox