I am trying to summarize some data in a data table, what I am attempting to do is to sum the total quantity of duplicate rows found.
My data table looks like this.
|ForeName|SurName|Quantity|
|Dave |Smith | 10000 |
|Dave |Smith | 20000 |
|Dave |Smith | 30000 |
|John |Peacock| 10000 |
I want to summarize this data to look like this.
|ForeName|SurName|Quantity|
|Dave |Smith | 60000 |
|John |Peacock| 10000 |
At the moment I am searching for duplicates in the data table
Dim duplicates = From rows In dt.AsEnumerable().GroupBy(Function(r) New With {Key .a = r("ForeName"), Key .b = r("SurName")}).Where(Function(gr) gr.Count() > 1).ToList()
However where to proceed from here I am unsure, has anyone ever came across a scenario like this and able to point me in the right direction.