Category | Product | Counts -------------------------------- 1 | Tea | 100 1 | Cofee | 102 2 | Pen | 23 2 | Den | 200 2 | Wen | 60 2 | Gen | 12 3 | Tip | 12 3 | Gip | 12 3 | Dip | 12
Category | Counts -------------------------------- 1 | 202 2 | 295 3 | 36
DataTable MainData = obj.DATA(); var query = from b in MainData.AsEnumerable() group b by b.Field<string>("Category") into Grp let _count = Convert.ToInt32( Grp.FirstOrDefault().Field<string>("_count")) orderby __count descending select new { Category= Grp.Key, Count = _count };
var result = MainData.AsEnumerable() .Select(r=> new{ Category = r.Field<string>("Category"), Count =Convert.ToInt32( r.Field<string>("_count"))}) .GroupBy(x=>x.Category).Select(g=>new{Category=g.Key, Count=g.Sum(c=>c.Count)});
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)