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

Поиск
Список
Период
Сортировка
От Alberto Cabello Sánchez
Тема Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?
Дата
Msg-id 20140924193710.bd4b8c1de92a8b66ac98c297@unex.es
обсуждение исходный текст
Ответ на Why can't I select un-grouped columns when grouping by a (non-primary) unique key?  (Daniel Lenski <dlenski@gmail.com>)
Ответы Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?  (Geoff Montee <geoff.montee@gmail.com>)
Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?  (Daniel Lenski <dlenski@gmail.com>)
Список pgsql-general
On Wed, 24 Sep 2014 09:04:21 -0700
Daniel Lenski <dlenski@gmail.com> wrote:

> If I include the primary key of a table in my GROUP BY clause, PG 9.3
> allows me to refer to other columns of that table without explicit GROUP BY:
>
> Why doesn't the same thing work with a non-NULL unique constraint?

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


--
Alberto Cabello Sánchez
<alberto@unex.es>


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

Предыдущее
От: Bill Moran
Дата:
Сообщение: Re: deadlock of lock-waits (on transaction and on tuple) using same update statement
Следующее
От: Geoff Montee
Дата:
Сообщение: Re: Why can't I select un-grouped columns when grouping by a (non-primary) unique key?