我想在两种不同的条件下获取同一个变量的总和。只是想知道是否有办法将这些加在一起。查询的细节并不太相关。基本上只是试图拿第一笔款项,并添加第二笔款项。SQL,如何从两个不同的查询中总结两个总和
例如 -
首先查询:
select sum(amt_tot)
from agbgift, aprdclb
where agbgift_id = '1' and agbgift_id = aprdclb_id
第二个查询:
select sum(amt_tot)
from agbgift, aprxref, aprdclb where
aprxref_id = '1' and
agbgift_id = aprxref_xref_id and
aprxref_id = aprdclb_id and
xref_code in ('SPS','BUS','ORG','OWN','FDN');
最终的结果我找的是 '第一个查询点心' +“第二个查询总和'
[子查询(http://dev.mysql.com /doc/refman/5.1/en/subqueries.html)? – 2014-09-26 17:24:55