0

Is it possible to use GroupBy in Linq to group by ranges of numbers? For instance if I have a large table of data, and want it to be grouped by say 0-20, 21-40, 41-60, 61-80, 81-100.

Is that possible and if so how would I accomplish that?

MattE
  • 1,044
  • 1
  • 14
  • 34
  • You want to do paging or what? 0-20 is this indexes of the rows ? – mybirthname Nov 05 '16 at 21:42
  • No, for instance let's say that is a students grade for example and I have a table of student grades, the class they are taking and what city they are in...I'd ike to be able to do something like group them by class, grade range and city so like Students taking Biology in Chicago and their grade ranges, students taking Chemistry in Chicago by their grade ranges, etc – MattE Nov 05 '16 at 21:44
  • OP, you are looking for ```Enumerable.Range(0, 101).GroupBy(x=>(x-1)/20)``` – tym32167 Nov 05 '16 at 21:52

0 Answers0