Re: GROUP BY or alternative means to group

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Michael Gould <mgould(at)isstrucksoftware(dot)net>
Cc: lxr(at)mac(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: GROUP BY or alternative means to group
Date: 2012-04-09 18:28:07
Message-ID: 20120409182807.GA13464@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Apr 09, 2012 at 13:55:04 -0400,
Michael Gould <mgould(at)isstrucksoftware(dot)net> wrote:
>Thanks that is a help. I would be nice if any key could be used as those are normally the things I would do group by's

This is what the 9.1 documentation says:
"When GROUP BY is present, it is not valid for the SELECT list expressions to
refer to ungrouped columns except within aggregate functions or if the
ungrouped column is functionally dependent on the grouped columns, since
there would otherwise be more than one possible value to return for an
ungrouped column. A functional dependency exists if the grouped columns (or
a subset thereof) are the primary key of the table containing the ungrouped
column."

That implies you need to group by a primary key. I haven't tested if
that (other keys can't provide this) is actually the case.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2012-04-09 18:51:19 Re: Resize numeric column without changing data?
Previous Message Michael Gould 2012-04-09 17:55:04 Re: GROUP BY or alternative means to group