X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D8D7C475DD7 for ; Sat, 22 Feb 2003 14:45:02 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 20945-05 for ; Sat, 22 Feb 2003 14:44:52 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id D00C9475D70 for ; Sat, 22 Feb 2003 14:35:21 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2852952; Sat, 22 Feb 2003 11:35:21 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Peter Eisentraut , Dan Langille Subject: Re: 7.3 "group by" issue Date: Sat, 22 Feb 2003 11:34:45 -0800 User-Agent: KMail/1.4.3 Cc: Chad Thompson , References: In-Reply-To: MIME-Version: 1.0 Message-Id: <200302221134.45226.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/502 X-Sequence-Number: 11900 Peter, > This does not work because the first select list item references a column > inside a join, which is not (necessarily) mathematically identical to the > column that arrives outside of the join and is in the GROUP BY clause. > (Think of an outer join: the column outside the join might contain added > null values. Of course you are using an inner join, but the constructs > work the same either way.) Hmmm ... I don't see that. I can see that it might be practically=20 difficult-to-impossible to make the planner distinguish between cases where= =20 the columns in the select list are different from the columns in the JOIN= =20 series and when they aren't, but as a theory issue I just don't buy it. What Dan's doing is: SELECT a.c1, count(a.c2) FROM a JOIN b WHERE b.c5 =3D x GROUP BY c1 In a case like this, a.c1 =3D=3D c1 without possibility of ambiguity. The = only=20 difference is whether or not a table qualifier is used on the name, which i= n=20 theory should *only* make a difference when there are more than one table i= n=20 the query with that column name.=20=20=20 So if you're saying that that kind of equivalency is a challenging parser= =20 implementation issue, then I'm with you. If you're saying its a SQL theor= y=20 issue, though, I don't agree at all. --=20 Josh Berkus Aglio Database Solutions San Francisco