我有一张这样的桌子。
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组计算
我只有一组
var thirdResultQuery=from row in secondResultQuery
group row by new {row.Grp } into g
select new
{
g.Key.Grp,
ageCount = g.Count()
};
有什么想法吗?
答案 0 :(得分: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()
};