pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Min values?
2+ messages / 2 participants
[nested] [flat]

* Min values?
@ 2003-03-17 16:48  J.C.M. van der Kwast <jkwast@home.nl>
  0 siblings, 0 replies; 2+ messages in thread

From: J.C.M. van der Kwast @ 2003-03-17 16:48 UTC (permalink / raw)
  To: pgsql-sql

Hi,

I don't seem to grasp the anwser on this problem. I've got a table with points, 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= (select points from table having distance = (select min(distance) from table)

The only result I'm getting is the min value of distance. I want to have the points, place_id with distance = min(distance). Any suggestions?

greetz Sjors

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Min values?
@ 2003-03-18 11:36  Christoph Haller <ch@rodos.fzk.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Christoph Haller @ 2003-03-18 11:36 UTC (permalink / raw)
  To: pgsql-sql; +Cc: jkwast@home.nl

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-03-18 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-17 16:48 Min values? J.C.M. van der Kwast <jkwast@home.nl>
2003-03-18 11:36 Re: Min values? Christoph Haller <ch@rodos.fzk.de>

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