Re: BUG #7486: Error Group by

From: Daniel Farina <daniel(at)heroku(dot)com>
To: andersonabreu(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7486: Error Group by
Date: 2012-08-11 09:13:03
Message-ID: CAAZKuFbLUxde-pMo65mURbFj1Mp0rxLCDHwSvBrL47qC9SiuKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Aug 10, 2012 at 10:33 AM, <andersonabreu(at)gmail(dot)com> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 7486
> Logged by: Anderson Abreu
> Email address: andersonabreu(at)gmail(dot)com
> PostgreSQL version: 8.4.12
> Operating system: Linux
> Description:
>
> Dear,
>
> I'm test the script, for example: select attA, attB from table1 group by
> attA.
>
> In postgre 8.4.X show error column attB must appear in the GROUP BY clause
> or be used in an aggregate function.
>
> But, in postgre 9.1.X the query running sucesfully.
>
> Why?

attA is probably a primary key, is that the case?

http://www.postgresql.org/docs/9.1/static/release-9-1.html#AEN107670

"Allow non-GROUP BY columns in the query target list when the primary
key is specified in the GROUP BY clause (Peter Eisentraut)

The SQL standard allows this behavior, and because of the primary key,
the result is unambiguous."

--
fdr

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message hubert depesz lubaczewski 2012-08-11 10:53:32 Bug when changing datatype of primary key column
Previous Message andersonabreu 2012-08-10 17:33:23 BUG #7486: Error Group by