pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: How change col name during query to use it in where clause
Date: Fri, 04 May 2012 15:05:43 +0200
Message-ID: <jo0k46$qhf$1@dough.gmane.org> (raw)
In-Reply-To: <4FA3AEA9.6010401@marcelruff.info>
References: <4FA3AEA9.6010401@marcelruff.info>

Marcel Ruff, 04.05.2012 12:25:
> Hi,
>
> is an alias name not usable in the where clause?
>
> select EXTRACT(day from enddate::TIMESTAMP - old_enddate::TIMESTAMP) AS TAGE from account_h where TAGE>5;
> ERROR: column "tage" does not exist
> LINE 1: ... TAGE>5 ...

You need to wrap the query:

select *
from (
    select EXTRACT(day from enddate::TIMESTAMP - old_enddate::TIMESTAMP) AS TAGE
    from account_h
) t
where TAGE > 5;






view thread (4+ messages)

Message-ID: <jo0k46$qhf$1@dough.gmane.org>
Permalink:  ../jo0k46$qhf$1@dough.gmane.org/
Also on:    postgresql.org/message-id/jo0k46$qhf$1@dough.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: How change col name during query to use it in where clause
  In-Reply-To: <jo0k46$qhf$1@dough.gmane.org>

* 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