Re: how to group by a joined query? - Mailing list pgsql-general

From Tom Lane
Subject Re: how to group by a joined query?
Date
Msg-id 513.1062421133@sss.pgh.pa.us
Whole thread Raw
In response to how to group by a joined query?  (Weiping He <laser@zhengmai.com.cn>)
List pgsql-general
Weiping He <laser@zhengmai.com.cn> writes:
> laser_uni=# select t1.name, t1.addr, t2.name, t2.len, t2.of from t1
> right join t2 on t1.name=t2.name group by t2.name;
> ERROR:  Attribute t1.name must be GROUPed or used in an aggregate function

> seems the I must gorup all those fields:

> is it specification compliant or postgresql specific?

It's spec-compliant according to SQL92.

There is some amazingly complex verbiage in SQL99 that seems intended to
allow the system to deduce that some GROUP BY specs are redundant and
can be omitted.  We don't implement that (yet) and I don't think it
would apply to your example anyway, since neither table's name column
is marked as primary key.

            regards, tom lane

pgsql-general by date:

Previous
From: Paul Thomas
Date:
Subject: Re: About GPL and proprietary software
Next
From: "Bruno BAGUETTE"
Date:
Subject: Where is the tool to migrate a mysql db to a PostgreSQL db ?