How to get uniqe rows only based on two columns

Hi Guys my question is related to the above post ,
I will need to get all the uniqe rows based on 2 columns
but currently my studio is working in a VB environment

thank you for the help.
Regards
Steve

Hi @StevenIsRobotOnline ,
They are same,
Can you share your input and expect output?
Regards
LNV

Input also same as the post above
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

output also save as above
column1, column2,column3,column4
ABC,xxx,123,yyy
tys,yyy,343,yyy
yru,ooo,999,ppp

thanks

Hi,

Can you try the following expression? This creates group from 3 columns. please modify it for your requirement.

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

Regards,

works like a charm thank you

1 Like

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