Re: [BUGS] Bug with a join and group by query. - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: [BUGS] Bug with a join and group by query.
Date
Msg-id 199902220242.VAA08570@candle.pha.pa.us
Whole thread Raw
In response to Bug with a join and group by query.  (Michael Richards <miker@scifair.acadiau.ca>)
List 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@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-bugs by date:

Previous
From: Michael Richards
Date:
Subject: Bug with a join and group by query.
Next
From: Unprivileged user
Date:
Subject: General Bug Report: JDBC driver metadata error