X-Original-To: pgsql-sql@postgresql.org Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (Postfix) with SMTP id E52B647616D for ; Tue, 18 Mar 2003 06:36:39 -0500 (EST) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Tue Mar 18 12:36:41 2003 +0100 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id MAA08015; Tue, 18 Mar 2003 12:36:41 +0100 (MET) Message-ID: <3E7704C8.CF2561DF@rodos.fzk.de> Date: Tue, 18 Mar 2003 12:36:40 +0100 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Cc: jkwast@home.nl Subject: Re: Min values? Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/430 X-Sequence-Number: 12469 > > I don't seem to grasp the anwser on this problem. I've got a table with poi= > nts, place_id's and distance between points and place_id. I want to select = > the points and place_id with smallest distance. I've tried statemeants like= > this but with no results that I like: > > Select points, place_id, distance from table > group by points, place_id, distance > having points=3D (select points from table having distance =3D (select min(= > distance) from table) > > The only result I'm getting is the min value of distance. I want to have th= > e points, place_id with distance =3D min(distance). Any suggestions? > Why not Select points, place_id, distance from table WHERE distance =3D (select min( distance) from table) ; Regards, Christoph