Problem with duplicates that are not really duplicates in SQL code SQL Server 2016 RRS feed

  • Question

  • I am having a super tough time trying to figure out how to place a flag on what I should keep and should not keep. Below is an example of the 1009 rows I have. I tried doing a case count on the case number and that helped with where the case number shows up more than 3 times for a decision by and was able to delete the duplicates that way where the max date is the same day but varying timestamp. I cannot get rid of timestamp and the reason is because the outcome say for 38089705 might be overturned on the 2nd row. The day is the same but the stamp varies and I need to take the last of that stamp. Where the day of something is the same day I take the max of that max date but where it is the next day or beyond I keep them all. So you see for example 38160243 I would keep both rows even though case number same and decision by same and outcome same but the records were touched on different days. I just am not sure how to code this so I can easily keep what is not a dupe in the eyes of corporate like 38160243 and then get rid of a dupe in the eyes of corporate which would be row 1 below for that case number. I am manually doing it now. Where I get the case count and started with 1, 3, and up and ran a delete on what I needed but now to =2 and 947 rows left and eyeballing this is nuts. The coding for this is just not in my brain maybe because I have spent 4 hours researching how to fix and hitting a road block.

    Friday, October 30, 2020 8:02 PM

All replies