I have a puzzle for all you sql fans.
Imagine a polygon with 12 sides (SideA, SideB, SideC, etc)
Within this polygon are 96 points (Pt1, Pt2, Pt3, etc).
Now let's say I have a table that has the distances from each point to each side
Point Side Distance
Pt1 SideA 25.6683
Pt1 SideB 37.6778
Pt1 SideC 576.8383
Pt2 SideA 352.2652
Pt2 SideB 3.8953
Pt2 SideC 46.9563
etc.
What I need to do is, for each point, find the two closest sides. So I need to sort on point name, find the two minimum values in Distance for that point, and report the side.
How do I do this? We are having a hard time wrapping our brains around the correct syntax.
Thanks for any help!
Imagine a polygon with 12 sides (SideA, SideB, SideC, etc)
Within this polygon are 96 points (Pt1, Pt2, Pt3, etc).
Now let's say I have a table that has the distances from each point to each side
Point Side Distance
Pt1 SideA 25.6683
Pt1 SideB 37.6778
Pt1 SideC 576.8383
Pt2 SideA 352.2652
Pt2 SideB 3.8953
Pt2 SideC 46.9563
etc.
What I need to do is, for each point, find the two closest sides. So I need to sort on point name, find the two minimum values in Distance for that point, and report the side.
How do I do this? We are having a hard time wrapping our brains around the correct syntax.
Thanks for any help!
Comment