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

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Rick Schumeyer <rschumeyer(at)ieee(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: pg, mysql comparison with "group by" clause
Date: 2005-10-11 21:32:45
Message-ID: 20051011142658.C54076@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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).

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Greg Patnude 2005-10-11 22:14:30 Re: SEVEN cross joins?!?!?
Previous Message Muralidharan Ramakrishnan 2005-10-11 21:27:48 Re: question re. count, group by, and having