Re: GROUPING - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: GROUPING
Date
Msg-id Pine.BSF.4.21.0110122220470.329-100000@megazone23.bigpanda.com
Whole thread Raw
In response to GROUPING  ("Timothy J Hitchens" <tim@hitcho.com.au>)
List 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>....



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: MEDIAN as custom aggregate?
Next
From: Masaru Sugawara
Date:
Subject: Re: MEDIAN as custom aggregate?