0
我的表是:总和
我通过查询得到这个纪录:
var result = (from r in context.tbl_PlantDemand
join d in context.tbl_NoOfPlantDemanded on r.Id equals d.PlantDemandId
join c in context.Clones on d.CloneId equals c.Id
where r.PifId == pifId
select new
{
FinancialYear = r.FinancialYearVal,
TypeId = r.PlantationType,
Amt = d.Demand
}).ToList();
输出:
FinancialYear TypeId Amt
---------------------------------
2015-16 1 100
2015-16 1 50
2015-16 1 20
2016-17 2 100
2016-17 2 10
我需要的总和结果Amt
视组别而定2列& typeId
FY TId Amt
--------------------
2015-16 1 170
2016-17 2 110
我可以很容易地按单列按列进行求和,但不知道如何求和多列。请让你不要被year
有一群我知道,如果有人知道
确定为第二,你需要130量不是110? –
@学习请检查我已更新。你是对的 –