Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aofJo-0001FS-Bc for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Apr 2016 22:56:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aofJn-00028Y-US for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Apr 2016 22:55:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aofJn-00028K-EG for pgsql-bugs@postgresql.org; Fri, 08 Apr 2016 22:55:59 +0000 Received: from hogranch.com ([75.101.82.47]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aofJk-0001jO-R0 for pgsql-bugs@postgresql.org; Fri, 08 Apr 2016 22:55:58 +0000 Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id u38LuEY20962; Fri, 8 Apr 2016 14:56:14 -0700 Subject: Re: BUG #14079: Issues with query To: hector.bejarano@gmail.com, pgsql-bugs@postgresql.org References: <20160408214743.15197.6247@wrigleys.postgresql.org> From: John R Pierce Message-ID: <570836F3.9090603@hogranch.com> Date: Fri, 8 Apr 2016 15:55:47 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <20160408214743.15197.6247@wrigleys.postgresql.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-HawgScanner-Information: Please contact the ISP for more information X-HawgScanner: Found to be clean X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 4/8/2016 2:47 PM, hector.bejarano@gmail.com wrote: > This query works: > select 1 as a > > But this one fails: > select 1 as a where a = 1 > > And I think they should both work. nope. doesn't work that way. Aliases to selected fields can not be used in the WHERE clause, because the WHERE clause is executed BEFORE the fields are selected and calculated. this is per the SQL standard. -- john r pierce, recycling bits in santa cruz -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs