From jkwast@home.nl Mon Mar 17 16:48:17 2003 X-Original-To: pgsql-sql@postgresql.org Received: from mail6-sh.home.nl (mail6.home.nl [213.51.128.20]) by postgresql.org (Postfix) with ESMTP id 6DE1A474E53 for ; Mon, 17 Mar 2003 11:48:17 -0500 (EST) Received: from cc299057a ([217.121.167.4]) by mail6-sh.home.nl (InterMail vM.5.01.05.17 201-253-122-126-117-20021021) with SMTP id <20030317164822.DXXQ21331.mail6-sh.home.nl@cc299057a> for ; Mon, 17 Mar 2003 17:48:22 +0100 Message-ID: <003901c2eca5$08c08970$04a779d9@cc299057a> From: "J.C.M. van der Kwast" To: Subject: Min values? Date: Mon, 17 Mar 2003 17:48:27 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0036_01C2ECAD.6A5BBE90" 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/407 X-Sequence-Number: 12446 This is a multi-part message in MIME format. ------=_NextPart_000_0036_01C2ECAD.6A5BBE90 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, 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? greetz Sjors ------=_NextPart_000_0036_01C2ECAD.6A5BBE90 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
I don't seem to grasp the anwser on t= his=20 problem. I've got a table with points, place_id's and distance between poin= ts=20 and place_id. I want to select the points and place_id with smallest distan= ce.=20 I've tried statemeants like this but with no results that I like:
 
Select points, place_id, distance from=20 table
group by points, place_id, distance=
having points=3D (select points from = table=20 having distance =3D (select min(distance) from table)
 
The only result I'm getting is the min val= ue of=20 distance. I want to have the points, place_id with distance =3D= =20 min(distance). Any suggestions?
 
greetz Sjors  
------=_NextPart_000_0036_01C2ECAD.6A5BBE90-- From ch@rodos.fzk.de Tue Mar 18 11:36:39 2003 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