From: Gerhard Dieringer <DieringG@eba-haus.de>
To: tesio@easynet.fr
Cc: " <"<pgsql-sql@postgresql.org>
Subject: Antw: Re: [SQL] group by / having
Date: Mon, 20 Dec 1999 10:30:10 +0100
Message-ID: <s85e0535.081@kopo001> (raw)
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: DieringG@eba-haus.de, tesio@easynet.fr, "<pgsql-sql@postgresql.org
Subject: Re: [SQL] group by / having
In-Reply-To: <s85e0535.081@kopo001>
References: <s85e0535.081@kopo001>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox