Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

[RESOLVED] delete all duplicate rows except one

$
0
0
Hi. I am posting this and at the same time will also be looking for the solution.

We have a database table of what employee is on call for any given day. If I had designed this table, it would've only allowed one row per date. But it is allowing duplicate rows which is creating a problem if the employee is different. For example what I attached in the screenshot is fine because the EmployeeID is always 48 and the SupervisorID is always 38. Still, why have these duplicates? I would like to delete 4 of the 5. I guess I would like the most recent one, according to LastUpdated/Control, be the one remaining.

The problem that needs addressing ASAP is going to be when I have a row with id's 48 and 38, Employee and SUpervisor respectively, and another with id's 67 and 48. I only want to keep one of those. I will have to talk to dispatch here and find out who is supposed to be oncall and fix it manually. I'm hoping there aren't a lot of those and I think those will be easier to find if I address the duplicates explained above, first.

So I want to find duplicate rows, with the same oncalldate, oncallemployeeid and oncallsupervisorid and delete all except one; the one that has the greated Control # can stay. Can you help me write that?
Attached Images
 

Viewing all articles
Browse latest Browse all 2918

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>