Re: GROUPING

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Timothy J Hitchens <tim(at)hitcho(dot)com(dot)au>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: GROUPING
Date: 2001-10-13 05:26:20
Message-ID: Pine.BSF.4.21.0110122220470.329-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sat, 13 Oct 2001, Timothy J Hitchens wrote:

> It's been a while since I used postgresql but today I have converted one
> of my web apps but with one small problem. I goto do a group as
> designed and executed in mysql and I get told that this and this must be
> part of the aggreate etc I am puzzled and wonder if someone could bring
> me up to stratch with grouping in postgresql this is my current sql:
>
> SELECT * FROM telemetry WHERE beat > 12 GROUP BY buid;
>
> Result:
>
> Attribute telemetry.rpvuid must be GROUPed or used in an aggregate
> function
>
>
> Oh then if I include rpvuid I get you must include this field and on it
> goes.
>
> Thanks...

Well, that query doesn't necessarily return consistant results.
Let's say you have a table
a | b
-----
1 | 1
1 | 2
2 | 3

What should select * from table group by a; give? There are two
values of b that could be chosen for that group.

I believe the appropriate part of the spec is
from query specification (7.9 of my draft)

7) If T is a grouped table, then each <column reference> in each
<value expression> that references a column of T shall refer-
ence a grouping column or be specified within a <set function
specification>....

In response to

  • GROUPING at 2001-10-13 01:15:03 from Timothy J Hitchens

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-10-13 05:31:54 Re: MEDIAN as custom aggregate?
Previous Message Bruce Momjian 2001-10-13 03:54:26 Re: VARCHAR vs TEXT