Re: problem with query and group by error

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with query and group by error
Date: 2014-02-21 19:34:37
Message-ID: 1393011277471-5793140.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Susan Cassidy-3 wrote
> Someone said something about
> "Yes, except those that are inside the aggregate."
> but I don't have an aggregate specified.

So every column then...

As soon as you add "group by" the rule becomes - every column is either a
group determinate or is aggregated. If you simply want to remove duplicates
you can write:

Select distinct ... From

No group by clause required and every output column is used to create an
implicit non-duplicated group.

I haven't tried to figure out what you are trying to do with this query so I
don't know which, if either, form is more correct but grouping without
aggregates is unusual and I also find that using distinct is not that common
a need of you have a correctly normalized database. IOW you should not use
group by or distinct to "make the query work" but only if you
know/understand why doing so is necessary.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/problem-with-query-and-group-by-error-tp5793127p5793140.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brian Crowell 2014-02-21 21:12:39 Re: GSSAPI server side on Linux, SSPI client side on Windows
Previous Message Susan Cassidy 2014-02-21 19:15:45 Re: problem with query and group by error