Re: problem with query and group by error

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: problem with query and group by error
Дата
Msg-id 1393011277471-5793140.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: problem with query and group by error  (Susan Cassidy <susan.cassidy@decisionsciencescorp.com>)
Список 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: Susan Cassidy
Дата:
Сообщение: Re: problem with query and group by error
Следующее
От: Brian Crowell
Дата:
Сообщение: Re: GSSAPI server side on Linux, SSPI client side on Windows