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