What's wrong with this group by clause? - Mailing list pgsql-sql

From Franco Bruno Borghesi
Subject What's wrong with this group by clause?
Date
Msg-id 200311041828.13144.franco@akyasociados.com.ar
Whole thread Raw
Responses Re: What's wrong with this group by clause?  (Manfred Koizar <mkoi-pg@aon.at>)
List pgsql-sql
Hi everyone.

Below you can find a simplified example of a real case.
I don't understand why I'm getting the "john" record twice.
I know there's no point in using constants in the group by, but makes sense in
the real much bigger query.
What I see is that when I issue an EXPLAIN with this query, it tells me that
the SORT KEY is "0".
When I remove one of the constant fields and try again the EXPLAIN, it says
that the SORT KEY is "0, name" (and the group by works, it shows only one
record for each person in the table).

Thanks anyone.

/*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)

pgsql-sql by date:

Previous
From: "Ryan"
Date:
Subject: nearest match
Next
From: "vincent"
Date:
Subject: Function calling error in postgreSQL 7.3.1