How change col name during query to use it in where clause
How change col name during query to use it in where clause
От:
Marcel Ruff <mr@marcelruff.info>
Дата:
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
Re: How change col name during query to use it in where clause
От:
"Oliveiros d'Azevedo Cristina" <oliveiros.cristina@marktest.pt>
Дата:
I'm affraid you can't. AFAIK, WHERE clause is processed before the SELECT output expressions Best, Oliveiros ----- Original Message ----- From: "Marcel Ruff" To: 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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql
Re: How change col name during query to use it in where clause
От:
Andreas Kretschmer <andreas@a-kretschmer.de>
Дата:
Marcel Ruff hat am 4. Mai 2012 um 12:25 geschrieben: > Hi, > > is an alias name not usable in the where clause? Exactly. Andreas
Re: How change col name during query to use it in where clause
От:
Thomas Kellerer <spam_eater@gmx.net>
Дата:
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;