Click here to Skip to main content
12,350,971 members (36,197 online)
Rate this:
 
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 12 Jul 2013
Copyright © CodeProject, 1999-2016
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