Click here to Skip to main content
11,644,136 members (75,279 online)
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 OriginalGriff 570
1 jyo.net 484
2 DamithSL 318
3 Afzaal Ahmad Zeeshan 253
4 CPallini 222
0 OriginalGriff 795
1 DamithSL 611
2 Mika Wendelius 494
3 jyo.net 484
4 Afzaal Ahmad Zeeshan 404


Advertise | Privacy | Mobile
Web03 | 2.8.150731.1 | Last Updated 12 Jul 2013
Copyright © CodeProject, 1999-2015
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