Re: how to group by a joined query?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Weiping He <laser(at)zhengmai(dot)com(dot)cn>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to group by a joined query?
Date: 2003-09-01 12:58:53
Message-ID: 513.1062421133@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Weiping He <laser(at)zhengmai(dot)com(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno BAGUETTE 2003-09-01 13:14:03 Where is the tool to migrate a mysql db to a PostgreSQL db ?
Previous Message Satish Kumar 2003-09-01 12:42:44 Query