Click here to Skip to main content
13,138,857 members (56,018 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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
Updated 11-Jul-13 20:05pm

1 solution

Rate this: bad
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;

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 |
Web02 | 2.8.170915.1 | Last Updated 12 Jul 2013
Copyright © CodeProject, 1999-2017
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