I have a data table that contains duplicate records ( See table pasted below). I want to group all duplicates (duplicate values vary in qty) and write to another table all duplicate values minus 1. The end state is to provide a listing of all duplicate values to delete except 1.
Is there a Linq statement out there? I tried coming up with looping logic to compare current row with next row but I would come across a scenario where my if statements would get to nested and when a new record that did not match previous record was encountered I would have to reset and my brain hurts now. Any help would be great!
ID 1 | ID 2 (Boss) |
---|---|
005891271484731W111517BA | 005891271484731W111517BA |
005891271484731W111517BA | 005891271484731W111517BA |
005891271480501W111520DA | 005891271480501W111520DA |
005891271480501W111520DA | 005891271480501W111520DA |
005891271480501W111520DA | 005891271480501W111520DA |
005891271480501W111520DA | 005891271480501W111520DA |
0058912711330339W111518AA | 0058912711330339W111518AA |
0058912711330339W111518AA | 0058912711330339W111518AA |
New Table to provide for deletion
|005891271484731W111517BA|005891271484731W111517BA|
|005891271480501W111520DA|005891271480501W111520DA|
|005891271480501W111520DA|005891271480501W111520DA|
|005891271480501W111520DA|005891271480501W111520DA|
|0058912711330339W111518AA|0058912711330339W111518AA|