Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7191775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:48:03+00:00 2026-05-28T19:48:03+00:00

In sql server 2005, I have a parent table describing paths, and a child

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:48:04+00:00Added an answer on May 28, 2026 at 7:48 pm
    DELETE FROM Points
    FROM points
    INNER JOIN     
    (SELECT point_id, path_id, n
     FROM (SELECT ROW_NUMBER() OVER(PARTITION BY path_id ORDER BY n DESC) AS RowNumber, 
                  point_id, path_id, n
           FROM points ) t
      WHERE n = 1 or RowNumber = 1 
    ) t on t.point_id = points.point_id and t.path_id = points.path_id and t.n = points.n
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's asume I have a parent-child structure setup in SQL (server 2005): CREATE TABLE
I have a table in my sql server 2005 database which contains about 50
SQL Server 2005 I have a table which returns ID name prop value --------------------------
I'm using SQL SERVER 2005 and have a table which stores challans datewise. It
I’m using SQL Server 2005 and I have a table contains a column of
I have two tables in an MS SQL Server 2005 database, parent and child,
I have a SQL Server 2005 legacy database which has a table named user
sql server 2005 : i have a column empid in employee table with identity
In SQL Server 2005 I have an id field in a table that has
[using SQL Server 2005] I have a table full of users, I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.