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

From Ryan Delaney
Subject SELECT, GROUP BY, and aggregates
Date
Msg-id 20150213050449.GQ5672@gmail.com
Whole thread Raw
Responses Re: SELECT, GROUP BY, and aggregates  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
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?

If I do this, Postgres throws an exception that I cannot SELECT a series of
columns including an aggregate without a corresponding GROUP BY clause. But it
knew to throw the error, right?  It must have some method of knowing which
columns aren't part of an aggregate.  Or is it that a column might not have an
aggregate, but still be hard to figure out how to group by it?

But how would that happen?

If I omit something from GROUP BY, it throws another exception. If I put
something there that doesn't belong, I get a different exception. So it already
knows how to do this! :P
--
Regards,
Ryan Delaney
ryan.delaney@gmail.com
https://github.com/rpdelaney
GPG ID: 4096R/311C 10F2 26E0 14E3 8BA4  3B06 B634 36F1 C9E7 771B

Attachment

pgsql-general by date:

Previous
From: seb
Date:
Subject: No repo for postgresql 9.4 for raspberry pi 2
Next
From: Saimon Lim
Date:
Subject: Re: How to hide stored procedure's bodies from specific user