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

  • Home
  • SEARCH
  • 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 8801835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:56:09+00:00 2026-06-14T00:56:09+00:00

Due to a bug in my application a table that was built to carry

  • 0

Due to a bug in my application a table that was built to carry daily records of each delivery period, was populated many times.

Lets say I have a delivery from 1st of June to 5 of June. My table should be populated with 5 records, one for each day. Now, I have havoc because I have many “batches” of the same content.

The table layout is as:

dummy_id       -- identity column
delivery_id    -- id of the delivery
on_date        -- the day
charge         -- the daily cost

Is there an elegant way to keep only the first batch of records and delete the batches that were inserted by mistake for all the deliveries?

  • 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-06-14T00:56:10+00:00Added an answer on June 14, 2026 at 12:56 am

    To delete all dupes for delivery_id, on_date, charge keeping the one with the lowest dummy_id

    ;WITH cte
         AS (SELECT ROW_NUMBER() OVER (PARTITION BY delivery_id,
                                                    on_date,
                                                    charge
                                           ORDER BY dummy_id) RN
             FROM   YourTable)
    DELETE FROM cte
    WHERE  RN > 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is an example program that has a bug due to _ReadBarrier() not being
I have a C++ program that crashed due to a bug. It would not
I have found a weird bug in my application and due to my small
The web-application is a custom-built CMS which has several sub-applications and each one of
It was a bug that I just found! Hooray. The bug was due to
Due to a bug in my javascript click handling, multiple Location objects are posted
Due to a bug in Flash, I have to use the ASPXAuth cookie to
I came across this due to a bug in my code and I'm curious
I've lost some time with a bug in my app due to user authentication.
I am trying to create an MVC3 C# simple application that uses facebook 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.