Remove a certain row from the Datatable [modified]
-
Hi All, I have a datatable : id name duration 01 001 00:10 02 002 00:20 03 003 00:10 As you can see, rows 0 and 2 have the same duration: 00:10 Now how can i make a algorimte to remove all those rows(except ONE of those rows) that has the same duration from my datatable ? Thanx.
modified on Sunday, July 20, 2008 8:20 AM
-
Hi All, I have a datatable : id name duration 01 001 00:10 02 002 00:20 03 003 00:10 As you can see, rows 0 and 2 have the same duration: 00:10 Now how can i make a algorimte to remove all those rows(except ONE of those rows) that has the same duration from my datatable ? Thanx.
modified on Sunday, July 20, 2008 8:20 AM
-
Hi All, I have a datatable : id name duration 01 001 00:10 02 002 00:20 03 003 00:10 As you can see, rows 0 and 2 have the same duration: 00:10 Now how can i make a algorimte to remove all those rows(except ONE of those rows) that has the same duration from my datatable ? Thanx.
modified on Sunday, July 20, 2008 8:20 AM
Group by duration and use
min(id)
to get one of the records to keep, and usehaving
to get the ones where count(*) > 1. Now join this result in a delete on the table, and specify the ones where id is different and duration is the same.Despite everything, the person most likely to be fooling you next is yourself.