Re: SELECT, GROUP BY, and aggregates - Mailing list pgsql-general

From Tom Lane
Subject Re: SELECT, GROUP BY, and aggregates
Date
Msg-id 28493.1423851182@sss.pgh.pa.us
Whole thread Raw
In response to SELECT, GROUP BY, and aggregates  (Ryan Delaney <ryan.delaney@gmail.com>)
Responses Re: SELECT, GROUP BY, and aggregates  (Bill Moran <wmoran@potentialtech.com>)
List pgsql-general
Ryan Delaney <ryan.delaney@gmail.com> writes:
> Why couldn't an RDBMS such as postgres interpret a SELECT that omits the GROUP
> BY as implicitly grouping by all the columns that aren't part of an aggregate?

Per SQL standard, a SELECT with aggregates but no GROUP BY is supposed to
give exactly one row.  What you suggest would not do that.

In general we're not that much into assigning made-up semantics to cases
that are specifically disallowed by the spec.  It's usually not too
obvious what the result "should be", so we run the risk that the SQL
committee might someday make a contrary decision.  More, this would lose
error detection, and reduce interoperability with other DBMSes that follow
the spec more faithfully.

            regards, tom lane


pgsql-general by date:

Previous
From: Sergey Burladyan
Date:
Subject: Contrib build fault for pgdg postgres 9.2 at debian 6 (squeeze)
Next
From: Tom Lane
Date:
Subject: Re: Contrib build fault for pgdg postgres 9.2 at debian 6 (squeeze)