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?
To delete all dupes for
delivery_id, on_date, chargekeeping the one with the lowestdummy_id