Improving GROUP BY?

Поиск
Список
Период
Сортировка
Искать
От
Oliver Siegmar
Тема
Improving GROUP BY?
Дата
Msg-id
200509300903.01112.oliver@siegmar.net
Список
Дерево обсуждения
Improving GROUP BY? Oliver Siegmar <oliver@siegmar.net>
Re: Improving GROUP BY? John Seberg <johnseberg@yahoo.com>
Re: Improving GROUP BY? Peter Eisentraut <peter_e@gmx.net>
Re: Improving GROUP BY? Oliver Siegmar <oliver@siegmar.net>
Re: Improving GROUP BY? Tom Lane <tgl@sss.pgh.pa.us>
Hello,

as you all may know, the GROUP BY clause in PostgreSQL has to be parameterized 
with all fields that appear in the SELECT clause (except aggregates).

So

SELECT   id, foo, sum(bar)
FROM     table1
GROUP BY id, foo;

is perfectly valid, where

SELECT   id, foo, sum(bar)
FROM     table1
GROUP BY id;

would fail with something like '"foo" must appear in the GROUP BY clause or be 
used in an aggregate function'.


I understand that behaviour in the case that the 'id' field wouldn't be a 
primary (or unique) identifier of the table.

So my questions are

- Would it be possible to add a feature to PostgreSQL to allow grouping by 
unique identifiers only?
- Is this requirement (all fields in GROUP BY) based on the SQL standard? If 
yes, by which version?



Best

Oliver
В списке pgsql-general по дате отправления
От: Rafael Montoya
Дата:
Сообщение: Hardware requirements
От: Peter Eisentraut
Дата:
Сообщение: Re: Improving GROUP BY?
FAQ