In sql server 2005, I have a parent table describing paths, and a child table which contains the coordinates for each point along each path, like this:
Path
int path_id, string path_name
Points
int path_id, float x, float y, int n
The first point on the path is n=1, and then each new point that is added increments n.
What I need to do is, delete the points returned by this:
select [path_id]
from Points
where n=1
i.e. the first point in each path, and then also delete all the points where n is the value returned by this:
select [path_id], max(n)
from Points
group by [path_id]
i.e. the last added point to each path.
For the first part, I can do this:
delete from Points
where n=1
but how do I do the second part?
1 Answer