Antw: Re: [SQL] group by / having
Gerhard Dieringer <dieringg@eba-haus.de>
From: "Gerhard Dieringer" <DieringG@eba-haus.de>
To: <tesio@easynet.fr>
Cc: "<"<pgsql-sql@postgresql.org>
Date: 1999-12-20T09:30:10Z
Lists: pgsql-sql
> X Y Z
> 1 1 A
> 1 2 B
> 2 1 C
> 3 1 D
> 3 2 E
> 3 3 F
>
> I want one line for each X value where the Y value is minimal, and I want
> to get the T column also.
select T1.X, T1.Y, T1.Z
from T T1
where T1.Y=(select min(T2.Y)
from T T2
where T1.X = T2.X);
should give you the right answer (not tested)
Gerhard