Merge datatable rows with same date and sum quantity

Hi all,

can any one help with linq query for merging a datatable rows with same date and sum the quantity for individual dates.


1 Like

from u in dateQties group u by u.Date into tmp select new { Date = tmp.Key, SumQty = tmp.Sum(p => p.Qty) };

@balu Check this Linq Query :
(From p In DT.AsEnumerable() Group By x= New With { Key.a =p.Item(“Date”)} Into Grp = Group Select DT.Clone.LoadDataRow (New Object() {grp(0)(0),grp.Sum(Function ( r ) if(String.IsNullOrEmpty(r(“Qty”).ToString) or String.IsNullOrWhiteSpace(r(“Qty”).ToString),0,Convert.ToDouble(r(“Qty”).ToString)))},False)).CopyToDataTable


1 Like