Identify Unique rows based on specific columns

Hi @vishal_nachankar ,

I’d like to confirm your requirement.

If input data is as the following,

column1,column2,column3,column4
ABC,xxx,123,yyy
ABC,xxx,123,yyy
AAA,xxx,123,yyy
tys,yyy,334,yyy
tys,yyy,334,yyy
yru,ooo,999,ppp

Is expected output still the following?

column1, column2,column3,column4
ABC,xxx,123,yyy
tys,yyy,343,yyy
yru,ooo,999,ppp

OR

column1,column2,column3,column4
ABC,xxx,123,yyy
AAA,xxx,123,yyy
tys,yyy,334,yyy
yru,ooo,999,ppp

If former, the expression will be as the following.

dtResult = dt.AsEnumerable().GroupBy(r=>Tuple.Create(r["column2"].ToString(),r["column3"].ToString(),r["column4"].ToString())).Select(g=>g.First()).CopyToDataTable()

Regards,

1 Like