Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 465AD13C6999 for ; Fri, 4 May 2012 09:43:56 -0300 (ADT) Received: from iota.marktest.pt ([80.251.174.118] helo=hermes.marktest.pt) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SQHrV-0004i1-Ik for pgsql-sql@postgresql.org; Fri, 04 May 2012 12:43:55 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by hermes.marktest.pt (Postfix) with ESMTP id 8218A1A8436; Fri, 4 May 2012 13:43:40 +0100 (WEST) X-Virus-Scanned: amavisd-new at marktest.pt Received: from hermes.marktest.pt ([127.0.0.1]) by localhost (hermes.marktest.pt [127.0.0.1]) (amavisd-new, port 11124) with ESMTP id N63dY6xIunIJ; Fri, 4 May 2012 13:43:40 +0100 (WEST) Received: from Proteu (proteu.marktest.pt [10.61.90.54]) by hermes.marktest.pt (Postfix) with ESMTP id 5F6A21A8433; Fri, 4 May 2012 13:43:40 +0100 (WEST) Message-ID: <340C84580192462E94F2EF130C1C078D@marktestcr.marktest.pt> From: "Oliveiros d'Azevedo Cristina" To: "Marcel Ruff" , References: <4FA3AEA9.6010401@marcelruff.info> Subject: Re: How change col name during query to use it in where clause Date: Fri, 4 May 2012 13:43:37 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-15"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Pg-Spam-Score: -0.5 (/) X-Archive-Number: 201205/5 X-Sequence-Number: 36553 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