有没有简单的方法可以把市政、教育、教育申请号加在一起得到总数?

问题描述 投票:0回答:1

我想把“市政、教育、教育征用”加在一起,越简单越好。这给了我正在寻找的正确答案。这就是我目前的做法,想知道是否有办法缩短它。

'municipaltax' = epa.assessed_value \* (select tax_rate from EdmontonPropertyTaxRate where tax_rate_type = 'municipal' and tax_year = 2022)

'education' = epa.assessed_value \* (select tax_rate from EdmontonPropertyTaxRate where tax_rate_type = 'education' and tax_year = 2022)

'education requisition allowance' = epa.assessed_value \* (select tax_rate from EdmontonPropertyTaxRate where tax_rate_type = 'education requisition allowance' and tax_year = 2022)

'total tax' = (epa.assessed_value \* (select tax_rate from EdmontonPropertyTaxRate where tax_rate_type = 'municipal' and tax_year = 2022)) +
(epa.assessed_value \* (select tax_rate from EdmontonPropertyTaxRate where tax_rate_type = 'education' and tax_year = 2022)) +
(epa.assessed_value \* (select tax_rate from EdmontonPropertyTaxRate where tax_rate_type = 'education requisition allowance' and tax_year = 2022))
mysql sql join sum subquery
1个回答
0
投票

听起来你只是在寻找

epa.assessed_value * (select sum(tax_rate) from EdmontonPropertyTaxRate where tax_rate_type in ('municipal','education','education requisition allowance') and tax_year = 2022)
© www.soinside.com 2019 - 2024. All rights reserved.