3
我有一張這樣的桌子。linq count by 2 conditions
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()
};
任何想法?
哦,是啊..這是我以前的查詢添加
Age
。爲什麼我認爲這不起作用?謝謝你.. – william@william你以前的查詢是什麼? –
@ JW,你能回答嗎? http://stackoverflow.com/questions/14351780/combining-two-datatable-and-getting-the-amount-from-second-table-by-using-linq – william