Re: How change col name during query to use it in where clause

From: "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "Marcel Ruff" <mr(at)marcelruff(dot)info>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How change col name during query to use it in where clause
Date: 2012-05-04 12:43:37
Message-ID: 340C84580192462E94F2EF130C1C078D@marktestcr.marktest.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm affraid
you can't.

AFAIK,
WHERE clause is processed before the SELECT output expressions

Best,
Oliveiros
----- Original Message -----
From: "Marcel Ruff" <mr(at)marcelruff(dot)info>
To: <pgsql-sql(at)postgresql(dot)org>
Sent: Friday, May 04, 2012 11:25 AM
Subject: [SQL] How change col name during query to use it in where clause

> 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 ...
>
> Thank you
> Marcel
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Kellerer 2012-05-04 13:05:43 Re: How change col name during query to use it in where clause
Previous Message Andreas Kretschmer 2012-05-04 12:40:40 Re: How change col name during query to use it in where clause