i have a Datatable having following result from database
ID Name Class FeeName Amount
9 gumman hgjgh 6Th Fine 0
9 gumman hgjgh 6Th Tution Fee 3000
9 gumman hgjgh 6Th Lebority Fee 500
10 AAdil Hussain 5Th Fine 0
10 AAdil Hussain 5Th Tution Fee 3000
10 AAdil Hussain 5Th Lebority Fee 500
i want to sum up amount against each ID so i implement following code
Dim TotalAmount As New DataColumn("TotalAmount", GetType(Double), "Sum(Amount)")
Dtable.Columns.Add(TotalAmount)
But result is following
ID Name Class FeeName Amount TotalAmount
9 gumman hgjgh 6Th Fine 0 7000
9 gumman hgjgh 6Th Tution Fee 3000 7000
9 gumman hgjgh 6Th Lebority Fee 500 7000
10 AAdil Hussain 5Th Fine 0 7000
10 AAdil Hussain 5Th Tution Fee 3000 7000
10 AAdil Hussain 5Th Lebority Fee 500 7000
but i want to sum up amount against each Name or ID
i have not idea of LINQ
I’m afraid a
DataTable'sColumn-Expression cannotSUM(Amount)OVER(PARTITION BY ID).Here’s the LINQ solution: