X-Original-To: pgsql-sql@postgresql.org Received: from mail5-sh.home.nl (mail5.home.nl [213.51.128.16]) by postgresql.org (Postfix) with ESMTP id 4D285474E4F for ; Wed, 19 Mar 2003 10:07:33 -0500 (EST) Received: from cc299057a ([217.121.167.4]) by mail5-sh.home.nl (InterMail vM.5.01.05.17 201-253-122-126-117-20021021) with SMTP id <20030319150736.KOP17325.mail5-sh.home.nl@cc299057a> for ; Wed, 19 Mar 2003 16:07:36 +0100 Message-ID: <002b01c2ee29$4c57d690$04a779d9@cc299057a> From: "Sjors" To: References: <3E78767B.47CA0F73@rodos.fzk.de> Subject: Re: howto/min values Date: Wed, 19 Mar 2003 16:07:45 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Archive-Number: 200303/463 X-Sequence-Number: 12502 > > > No, not at all. Something like > > select p.points, p.id, p.distance from > (select points, id, (x-x) as distance from table) as p > where p.distance = (select min(p1.distance) > > from table as p1 > > where p.points=p1.points) > > order by p.points, p.id ; > > should do the trick. > The FROM clause allows any kind of subqueries within parentheses. > > Regards, Christoph > Thanks, this is the solution. greetz Sjors