X-Original-To: pgsql-hackers@postgresql.org Received: from email06.aon.at (WARSL401PIP3.highway.telekom.at [195.3.96.75]) by postgresql.org (Postfix) with SMTP id 42233476366 for ; Thu, 13 Mar 2003 10:18:13 -0500 (EST) Received: (qmail 260550 invoked from network); 13 Mar 2003 15:17:31 -0000 Received: from m170p023.dipool.highway.telekom.at (HELO cantor) ([62.46.11.55]) (envelope-sender ) by qmail6rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 13 Mar 2003 15:17:31 -0000 From: Manfred Koizar To: Franco Bruno Borghesi Cc: pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [SQL] What's wrong with this group by clause? Date: Thu, 13 Mar 2003 16:16:29 +0100 Message-ID: References: <200311041828.13144.franco@akyasociados.com.ar> In-Reply-To: <200311041828.13144.franco@akyasociados.com.ar> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/537 X-Sequence-Number: 36783 [forwarding to -hackers] On Tue, 4 Nov 2003 18:28:12 -0300, Franco Bruno Borghesi wrote: >Below you can find a simplified example of a real case. >I don't understand why I'm getting the "john" record twice. ISTM you have found a Postgres 7.3 bug. I get one john with PostgreSQL 7.1.3 on i686-pc-cygwin, compiled by GCC 2.95.3-5 and PostgreSQL 7.2 on i686-pc-linux-gnu, compiled by GCC 2.7.2.1 but two johns with PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.7.2.1 >/*EXAMPLE*/ >CREATE TABLE people >( > name TEXT >); >INSERT INTO people VALUES ('john'); >INSERT INTO people VALUES ('john'); >INSERT INTO people VALUES ('pete'); >INSERT INTO people VALUES ('pete'); >INSERT INTO people VALUES ('ernest'); >INSERT INTO people VALUES ('john'); > >SELECT > 0 AS field1, > 0 AS field2, > name >FROM > people >GROUP BY > field1, > field2, > name; > > field1 | field2 | name >--------+--------+-------- > 0 | 0 | john > 0 | 0 | pete > 0 | 0 | ernest > 0 | 0 | john >(4 rows) Same for SELECT 0 AS field1, 0 AS field2, name FROM people GROUP BY 1, 2, name; Servus Manfred