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

From: "Len Morgan" <len-morgan(at)crcom(dot)net>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: What's wrong with this group by clause?
Date: 2003-03-13 07:34:34
Message-ID: 00a201c2e932$fee5b9e0$0300a8c0@kttk.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From: Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar>
>SELECT
> 0 AS field1,
> 0 AS field2,
>name
>FROM
> people
>GROUP BY
> field1,
> field2,
>name;

I think the problem is that you don't have a column to group on. Try adding
SELECT ....,count(*).... so that there is an aggregate of some kind.
Alternatively, you could use DISTINCT ON (field1,field2) field1,field2,name
FROM ... although this is a Postgres specific extension of the SQL spec.

Len Morgan

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-03-13 08:57:02 Re: nearest match
Previous Message Stephan Szabo 2003-03-13 06:05:29 Re: Function calling error in postgreSQL 7.3.1