pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: pgsql-sql@postgresql.org
Cc: jkwast@home.nl
Subject: Re: Min values?
Date: Tue, 18 Mar 2003 12:36:40 +0100
Message-ID: <3E7704C8.CF2561DF@rodos.fzk.de> (raw)

>
> 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





view thread (2+ messages)

Message-ID: <3E7704C8.CF2561DF@rodos.fzk.de>
Permalink:  ../3E7704C8.CF2561DF@rodos.fzk.de/
Also on:    postgresql.org/message-id/3E7704C8.CF2561DF@rodos.fzk.de

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ch@rodos.fzk.de, jkwast@home.nl
  Subject: Re: Min values?
  In-Reply-To: <3E7704C8.CF2561DF@rodos.fzk.de>

* 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