I have a datatable (with 2 columns):
X Y
AA 100
BB 150
AA 25
BB 10
CC 120
As you can see for :
AA values the sum is 125
BB values the sum is 160
CC values the sum is 120
Them maximum sum is 160 for BB
I want to obtains this values, the maximum of sums, where sum is that of a grup, grouped on column X value, and also that X value.
How can I do this with LINQ in VB.NET ?
Thank you !
EDIT: This is the code that I'm using:
Dim marfa = _
From dr In dtMarfuriT _
Group dr By Key = dr("MRF_COD") Into Group _
Let maxim = Group.Sum(Function(dr) dr("MRF_MASA_STABILITA")) _
Select New With { _
Key .cod = Key, _
Key .TopMarfa = Group.First(Function(dr) Group.Sum(Function(drx) CDbl(drx("MRF_MASA_STABILITA"))) = maxim)("MRF_COD"), _
Key .Maximul = maxim}
Dim MasaMaxima As Double = marfa.Maximul
Dim CodulMaseiMaxime As String = marfa.TopMarfa