Skip site navigation (1) Skip section navigation (2)

Re: GROUP BY bug or feature?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: GROUP BY bug or feature?
Date: 2009-10-26 22:41:47
Message-ID: 16638.1256596907@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:
> INSERT INTO product.t_product_inv
> SELECT word, array_accum_1(price, id) FROM product.t_product_inv0
> GROUP BY word ORDER BY word, price NULLS FIRST, id;

> However, I get an error:

> ERROR:  column "t_product_inv0.price" must appear in the GROUP BY clause
> or be used in an aggregate function
> LINE 3: GROUP BY word ORDER BY word, price NULLS FIRST, id;
>                                      ^

> The condition in the error message  is true, the field "price"
> is indeed used in an aggregate function but ignored on purpose
> in the sfunc. So I obviously didn't expect the error to happen.

It is not complaining about the use in the aggregate.  It is complaining
about the un-aggregated use in ORDER BY.  Notice the error pointer.

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Pavel StehuleDate: 2009-10-26 22:53:33
Subject: Re: Anonymous Code Blocks as Lambdas?
Previous:From: Josh BerkusDate: 2009-10-26 22:30:30
Subject: Re: Parsing config files in a directory

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group