Re: What's wrong with this group by clause?

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: "Len Morgan" <len-morgan(at)crcom(dot)net>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: What's wrong with this group by clause?
Date: 2003-03-14 10:38:30
Message-ID: fhb37vsiacbvl4u9tqai03p806p28q3rej@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 13 Mar 2003 01:34:34 -0600, "Len Morgan"
<len-morgan(at)crcom(dot)net> wrote:
>>GROUP BY
> > field1,
> > field2,
> >name;
>I think the problem is that you don't have a column to group on.

field1, field2, and name are the grouping columns.

>Try adding
>SELECT ....,count(*).... so that there is an aggregate of some kind.

You don't need an aggregate in a GROUP BY query. A SELECT ... GROUP
BY without any aggregate behaves like SELECT DISTINCT. There's
nothing wrong with it. Performance might be a different story.

BTW, Franco's problem has been recognised as a bug and a patch has
already been published (cf. Tom Lane's mail in this thread).

Servus
Manfred

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2003-03-14 10:52:02 Re: View - Join based on dis-similar data types
Previous Message David Witham 2003-03-14 09:18:42 parse error when calling function in plpgsql