Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?

Поиск
Список
Период
Сортировка
От Daniel Lenski
Тема Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?
Дата
Msg-id CAOw_LSGWP1kSs6BhUS0f2ngb=Cckm3MwN6Q9Wm77Jadpz10S7A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?  (Alberto Cabello Sánchez <alberto@unex.es>)
Список pgsql-general
On Wed, Sep 24, 2014 at 10:37 AM, Alberto Cabello Sánchez
<alberto@unex.es> wrote:
> At first sight, primary key means no grouping at all, as there are no
> duplicated A.primary_key values:
>
>   SELECT A.document
>     FROM A
>     GROUP BY A.primary_key
>
> is the same as
>
>   SELECT A.document
>     FROM A
>

Yes, my example is oversimplified, because GROUP BY primary_key has no
semantic effect on a single-table query, although it still illustrates
the different behavior for PRIMARY KEY vs. UNIQUE NOT NULL, which
should be logically equivalent.

The examples that Geoff Montee gave are better because (GROUP BY
primary_key) does change the meaning of the query when there's a join
to another table.

Dan


В списке pgsql-general по дате отправления:

Предыдущее
От: Daniel Lenski
Дата:
Сообщение: Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?