Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 24 Sep 2014 09:04:21 -0700
Daniel Lenski <dlenski@xxxxxxxxx> 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@xxxxxxx>


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux