Data table how to remove duplicate rows

Hi Team,
I have one data table, table contains 4 columns,
First 3 columns any one column have unique values, so that scenario not a duplicate.

Dt1 : input


Dt2 : output

@AJITH_SK

check the reference

@AJITH_SK

dt = dt.AsEnumerable() _
    .GroupBy(Function(row) String.Join(",", row.ItemArray), Function(key) key.First()) _
    .CopyToDataTable()

I hope it helps

1 Like

@AJITH_SK

Can you try the below

image

DT.AsEnumerable() _
    .GroupBy(Function(row) row.Field(Of String)("Name") & row.Field(Of Integer)("Age") & row.Field(Of String)("City")) _
    .Select(Function(Group) Group.First()) _
    .CopyToDataTable()

Output:

image

Cheers!!

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.