From: | "Sjors" <jkwast(at)freeler(dot)nl> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | howto? |
Date: | 2003-03-17 17:09:31 |
Message-ID: | 008901c2eca7$fa181110$04a779d9@cc299057a |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
Being not able to grasp in full sql, I've decided to call on the list. I've got a table with points, place_id and distance between points and place_id. For each point there can be more place_id's but I want to selesct the one with the minimum distance. Now I can group by the points and select the min(distance) but I can't do this if place_id is involved. I used a statment like this:
Select points, place_id, distance from table
group by points, place_id, distance
having count(*)>1 and distance=(select min(distance) from table
This will give me 1 value being the minimum of all distances.
If only done on basis of points and distance I do get the minimum values, but then I don't have the place_id.
How can I get the minimum values of the place_id within in the group of points, being the same?
I've looked and played around with variations round but I can't figure out how to do this. Any suggestions??
greetz sjors
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-03-17 17:53:33 | Re: howto? |
Previous Message | J.C.M. van der Kwast | 2003-03-17 16:48:27 | Min values? |