select a.XM_MC as 项目名称,a.CR_JE as 出让金额 ,
sum(nvl(b.YD_JE,0)) - sum(nvl(c.SJ_JE,0)) as 欠缴金额,
max(b.YD_QH) as 约定支付期号,
max(b.YD_SJ) as 约定支付时间
from T_GDXM a , T_CRJ_ZFYD b ,T_CRJ_ZFSJ c
where a.GD_GUID =b.GD_GUID and a.GD_GUID =c.GD_GUID
and b.YD_SJ<sysdate and c.SJ_SJ <sysdate
group by a.XM_MC,a.CR_JE
------解决方案--------------------
参考sql: select a.XM_MC as 项目名称,a.CR_JE as 出让金额 , sum(nvl(b.YD_JE,0)) - sum(nvl(c.SJ_JE,0)) as 欠缴金额, max(b.YD_QH) as 约定支付期号, max(b.YD_SJ) as 约定支付时间 from T_GDXM a left join T_CRJ_ZFYD b on a.GD_GUID =b.GD_GUID and b.YD_SJ<sysdate left join T_CRJ_ZFSJ c on a.GD_GUID =c.GD_GUID and c.SJ_SJ <sysdate group by a.XM_MC,a.CR_JE
------解决方案--------------------