Re: Group By and wildcards...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Jon Lapham <lapham(at)jandr(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Group By and wildcards...
Date: 2005-02-19 17:40:40
Message-ID: 17799.1108834840@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> Jon Lapham <lapham(at)jandr(dot)org> wrote:
>> When using queries with aggregate functions, is there any way to not
>> have to have to explicitly write all the columns names after the GROUP
>> BY ? I would like to use a wildcard "*".

> Don't those tables have primary keys? Grouping by the primay key of each
> table will produce the same result set as grouping by all of the columns.

Unfortunately, PG will still make him GROUP BY everything he wants to
use as a non-aggregated output column. This behavior is per SQL92
spec. SQL99 added some verbiage to the effect that you only need to
GROUP BY columns that the rest are functionally dependent on (this
covers primary keys and some other cases); but we haven't got round
to implementing that extension.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-02-19 17:43:04 Re: How do I change sort order behavious with nulls
Previous Message Robby Russell 2005-02-19 17:38:59 Re: Client lib v. 7.3 to access 8.0 db server.