Re: [BUGS] Bug with a join and group by query.

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: miker(at)scifair(dot)acadiau(dot)ca (Michael Richards)
Cc: bugs(at)postgreSQL(dot)org
Subject: Re: [BUGS] Bug with a join and group by query.
Date: 1999-02-22 02:42:06
Message-ID: 199902220242.VAA08570@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> Hi.
> I think I found a bug. My query works in mysql.
> I have 2 tables. It's for a classifieds database. 1 is the categories, and
> the second is the postings. Postings are categorised and related to a
> category. I'll dump the contents of the tables and append it to the
> message if anyone wants test data.
>
> postgres 6.4 does:
> select cl_categories.catid,cl_categories.description,count(*) from
> cl_categories,cl_postings where catid=categoryid group by catid;
> ERROR: parser: illegal use of aggregates or non-group column in target
> list

You must group by all non-aggregate fields. That includes description.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Unprivileged user 1999-02-23 17:37:13 General Bug Report: JDBC driver metadata error
Previous Message Michael Richards 1999-02-22 02:03:04 Bug with a join and group by query.