Re: GROUP BY or alternative means to group - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: GROUP BY or alternative means to group
Date
Msg-id 20120409182807.GA13464@wolff.to
Whole thread Raw
In response to Re: GROUP BY or alternative means to group  (Michael Gould <mgould@isstrucksoftware.net>)
List pgsql-general
On Mon, Apr 09, 2012 at 13:55:04 -0400,
   Michael Gould <mgould@isstrucksoftware.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.

pgsql-general by date:

Previous
From: Michael Gould
Date:
Subject: Re: GROUP BY or alternative means to group
Next
From: Merlin Moncure
Date:
Subject: Re: Resize numeric column without changing data?