Apologies for the long winded question, let me explain it better.
I want to be able to:
Keep the top duplicate row
Sum column of the duplicate values and add it to the top duplicate row:
Below is an example - Company column is the column i want to remove duplicates, money column is where I want to add all the companies money together. So in the bottom of the image we can see that the duplicates have been removed, the top value has been kept and the total of the duplicates money has been added.
I have got this working using nested for each but it is slow and I would like it to be faster and not nested.
I was trying to use database.select() but didnt manage to come up with something.
(From d in YourOriginDataTableVar.AsEnumerable
Group d by k=d("Company").toString.Trim into grp=Group
Let sm = grp.Sum(Function (x) CInt(x("Money").toString.Trim))
Let ra = new Object(){k, grp.First()(1), sm, grp.First()(3), grp.First()(4)}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable