SQL 求和语句

SELECT SUM(zy_detail_charge.charge_amount) FROM zy_detail_charge where zy_detail_charge.charge_code in (select fee_code from or_level where  or_level = 'xt' and flag = '410')and data_month ='2010-08'SELECT SUM(mz_charge_detail.quantity) from mz_charge_detail where mz_charge_detail.charge_item_code in (select fee_code from or_level where  or_level = 'xt' and flag = '410')and data_month ='2010-08'    我要把这两条语句 加在一起求和 改怎么写求和语句。

第1个回答  推荐于2017-04-22
select sum(a.a) from
(
SELECT SUM(zy_detail_charge.charge_amount) FROM zy_detail_charge where zy_detail_charge.charge_code in (select fee_code from or_level where or_level = 'xt' and flag = '410')and data_month ='2010-08'
union all
SELECT SUM(mz_charge_detail.quantity) from mz_charge_detail where mz_charge_detail.charge_item_code in (select fee_code from or_level where or_level = 'xt' and flag = '410')and data_month ='2010-08'
) a(a)
第2个回答  2012-03-03
select sum(charge_amount)
from
(
查询A
union all
查询B
)
相似回答