3

我有一张这样的桌子。

Age Group

20  G1
21  G2
20  G2
21  G1
22  G3
21  G1
20  G2
21  G2
22  G3
20  G1
22  G3

我想要的结果是

Age Grp Count

20  G1 2 
20  G2 2
21  G1 2
22  G2 2
22  G3 3

我不知道如何按 2 组计算

我只有 1 组

   var thirdResultQuery=from row in secondResultQuery
                         group row by new {row.Grp  } into g
                         select new
                         {

                             g.Key.Grp,
                             ageCount = g.Count()
                         };

任何的想法?

4

1 回答 1

3

加入Age_GROUP

var thirdResultQuery    =   from row in secondResultQuery
                            group row by new {row.Grp, row.Age} into g
                            select new
                            {
                                g.Key.Age,
                                g.Key.Grp,
                                ageCount = g.Count()
                            };
于 2013-01-16T06:19:40.960 回答