日期:2014-05-18 浏览次数:20599 次
select
a.tablecode,a.taomoney+sum(b.[money]) as summoney
from
表1 a,表2 b
where
a.tablecode=b.tablecode and b.status='正常'
group by
a.tablecode,a.taomoney
order by
a.tablecode
------解决方案--------------------
select tablecode,sum(taomoney) as taomoney
from
(
select tablecode,taomoney
from 表1
union all
select tablecode,money
from 表2
where status='正常'
) T
group by tablecode