X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D405DD1D642 for ; Fri, 13 Feb 2004 15:15:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 11891-10 for ; Fri, 13 Feb 2004 11:15:34 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 6AEF2D1D2F7 for ; Fri, 13 Feb 2004 11:15:29 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1DFFVOP002374; Fri, 13 Feb 2004 10:15:32 -0500 (EST) To: Tomasz Myrta Cc: Lista dyskusyjna pgsql-sql Subject: Re: column alias and group by/having/order In-reply-to: <402CD27E.7050001@klaster.net> References: <402CD27E.7050001@klaster.net> Comments: In-reply-to Tomasz Myrta message dated "Fri, 13 Feb 2004 14:34:54 +0100" Date: Fri, 13 Feb 2004 10:15:31 -0500 Message-ID: <2373.1076685331@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/148 X-Sequence-Number: 16839 Tomasz Myrta writes: > I found some strange column alias behaviour: That's how it is. The fact that you can reference output-column aliases at all in GROUP BY or ORDER BY is a wart, because it conflicts with the logical model of query evaluation --- the output list should be computed last. We have extended the SQL92 requirement (unadorned aliases in ORDER BY) to allow the same in GROUP BY, but we don't take it to the level of allowing them inside arbitrary expressions. regards, tom lane