Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: LINQ
from a data table i have to group by a particular column, and sum it and find the top 10 rows to plot in chart using Linq
Posted 11-Jul-13 19:58pm
Edited 11-Jul-13 20:05pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Check out 101 LINQ Samples[^] from Microsoft.
Through this you should be able to find the right LINQ phrase.
 
But perhaps something like this can give you a start?
// Make the group first.
var groups = from row in rows
             group row by row.Column1 into g
             select new { GroupKey = g.Key, Value = g };
 
// Get top 10
var results = (from g in groups
               order by g.Value.Column2
               select g.Value).Take(10);
 
// look at the results
foreach (var result in results)
{
  var name = result.Column2;
}
 
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 547
1 Member 11120668 188
2 ChauhanAjay 180
3 Maciej Los 165
4 CHill60 135
0 Sergey Alexandrovich Kryukov 9,735
1 OriginalGriff 6,987
2 CPallini 5,835
3 George Jonsson 4,017
4 Gihan Liyanage 3,266


Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 12 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100