Re: Attribute must be GROUPed.... ?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Daniele Orlandi <daniele(at)orlandi(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Attribute must be GROUPed.... ?
Date: 2003-04-30 21:48:44
Message-ID: 20030430144643.O95283-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 30 Apr 2003, Daniele Orlandi wrote:

> I always had been doubious about the "must" in the error message
> "Attribute must be GROUPed or used in an aggregate function".

AFAIK it's a requirement of the SQL spec. (SQL92(draft) 7.9 SR 7, "each
<column reference> in each <value expression> that references a column
of T shall reference a grouping column or be specified within a <set
function specification>."

> For example, suppose that you join two tables and the field you group by
> appears to be the primary key of one of the tables. In this case if I
> put any of the fields in that table in the target list, it will always
> be well defined and would make certain queries much simpler.

Well, it'd mean you didn't have to put the extra columns in the group by
list to make them grouping columns.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniele Orlandi 2003-04-30 22:02:57 Re: Attribute must be GROUPed.... ?
Previous Message Joshua Drake 2003-04-30 21:39:48 Re: Upgrade to RedHat 9.0 broke PostgreSQL