英文:
Converting SQL query to Lambda
问题
SELECT a.assembly_name,
a.financial_year,
a.total_expenditure,
SUM(b.ac_bill_amount) AS TOTAL_AC_BILL
FROM fund_allotment AS a INNER JOIN mla_ac_bill AS b
ON a.assembly_name = b.assembly_name and a.financial_year = b.financial_year
GROUP BY a.assembly_name,a.financial_year,a.total_expenditure
英文:
Can anyone help me translate the below sql to lambda?
SELECT a.assembly_name,
a.financial_year,
a.total_expenditure,
SUM(b.ac_bill_amount) AS TOTAL_AC_BILL
FROM fund_allotment AS a INNER JOIN mla_ac_bill AS b
ON a.assembly_name = b.assembly_name and a.financial_year = b.financial_year
GROUP BY a.assembly_name,a.financial_year,a.total_expenditure
答案1
得分: 0
Here is the translated code:
var result = fundAllotment
.Join(mlaAcBill,
a => new { a.AssemblyName, a.FinancialYear },
b => new { b.AssemblyName, b.FinancialYear },
(a, b) => new
{
a.AssemblyName,
a.FinancialYear,
a.TotalExpenditure,
b.AC_Bill_Amount
})
.GroupBy(x => new
{
x.AssemblyName,
x.FinancialYear,
x.TotalExpenditure
})
.Select(g => new
{
g.Key.AssemblyName,
g.Key.FinancialYear,
g.Key.TotalExpenditure,
TotalACBill = g.Sum(x => x.AC_Bill_Amount)
});
Is there anything else you would like to translate?
英文:
var result = fundAllotment
.Join(mlaAcBill,
a => new { a.AssemblyName, a.FinancialYear },
b => new { b.AssemblyName, b.FinancialYear },
(a, b) => new
{
a.AssemblyName,
a.FinancialYear,
a.TotalExpenditure,
b.AC_Bill_Amount
})
.GroupBy(x => new
{
x.AssemblyName,
x.FinancialYear,
x.TotalExpenditure
})
.Select(g => new
{
g.Key.AssemblyName,
g.Key.FinancialYear,
g.Key.TotalExpenditure,
TotalACBill = g.Sum(x => x.AC_Bill_Amount)
});
答案2
得分: 0
以下是翻译好的部分:
在我看来,你想要这个:
from fa in fund_allotment
join mab in mla_ac_bill
on new { fa.assembly_name, fa.financial_year }
equals new { mab.assembly_name, mab.financial_year }
group mab.ac_bill_amount
by new { fa.assembly_name, fa.financial_year, fa.total_expenditure }
into g
select new
{
g.Key.assembly_name,
g.Key.financial_year,
g.Key.total_expenditure,
TOTAL_AC_BILL = g.Sum()
};
英文:
It seems to me that you want this:
from fa in fund_allotment
join mab in mla_ac_bill
on new { fa.assembly_name, fa.financial_year }
equals new { mab.assembly_name, mab.financial_year }
group mab.ac_bill_amount
by new { fa.assembly_name, fa.financial_year, fa.total_expenditure }
into g
select new
{
g.Key.assembly_name,
g.Key.financial_year,
g.Key.total_expenditure,
TOTAL_AC_BILL = g.Sum()
};
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论