Re: pg, mysql comparison with "group by" clause

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: pg, mysql comparison with "group by" clause
Дата
Msg-id 20051011142658.C54076@megazone.bigpanda.com
обсуждение исходный текст
Ответ на pg, mysql comparison with "group by" clause  ("Rick Schumeyer" <rschumeyer@ieee.org>)
Ответы Re: pg, mysql comparison with "group by" clause
Список pgsql-sql
On Tue, 11 Oct 2005, Rick Schumeyer wrote:

> I'm not sure what I was thinking, but I tried the following query in pg:
>
> SELECT * FROM t GROUP BY state;
>
> pg returns an error.
>
> Mysql, OTOH, returns the first row for each state.  (The first row with
> "AK", the first row with "PA", etc.)
>
> I'm no SQL expert, but it seems to me that the pg behavior is correct, and
> the mysql result is just weird.  Am I correct?

In your case, it sounds like the mysql result is wrong. I believe SQL99
would allow it if the other columns were functionally dependant upon state
(as there'd by definition only be one value for the other columns per
group).



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

Предыдущее
От: Muralidharan Ramakrishnan
Дата:
Сообщение: Re: question re. count, group by, and having
Следующее
От: "Greg Patnude"
Дата:
Сообщение: Re: SEVEN cross joins?!?!?