Remove rows with the same column value

Hello.
I have a table where the first column should be unique but isn’t set as unique by default. Hence, there may be rows with the same value in the first column. I would like to get those rows and select the first one of them everytime.

Here’s the input:

Num, Time
1, 11:10
2, 11:15
3, 11:17
3, 11:18
4, 11:20
5, 11:21
5, 11:22
5, 11:26
6, 11:32

The expected result is:
Num, Time
1, 11:10
2, 11:15
3, 11:17
4, 11:20
5, 11:21
6, 11:32

Hi @MGMKLML,

use below code

dt=dt.AsEnumerable().GroupBy(Function(i) i.Field(Of String)("Num")).Select(Function(g) g.First).CopyToDataTable()

Regards,
Arivu

1 Like