What's wrong with this group by clause?

Поиск
Список
Период
Сортировка
От Franco Bruno Borghesi
Тема What's wrong with this group by clause?
Дата
Msg-id 200311041828.13144.franco@akyasociados.com.ar
обсуждение исходный текст
Ответы Re: What's wrong with this group by clause?  (Manfred Koizar <mkoi-pg@aon.at>)
Список 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 по дате отправления:

Предыдущее
От: "Ryan"
Дата:
Сообщение: nearest match
Следующее
От: "vincent"
Дата:
Сообщение: Function calling error in postgreSQL 7.3.1