日期:2014-05-17 浏览次数:21136 次
select riid,cid,...from (...)rei left join (select ots.riid,sum(ots.ormoney) ormoney,ots.orexcuse,ots.ortype from (select o.riid,o.ortype,rt.rtname,o.orexcuse,o.ormoney from otherreimburse o left join reimbursetype rt on rt.rtname=o.ortype) ots group by ots.riid,ots.orexcuse,ots.ortype) otsr on rei.riid = otsr.riid and rei.cid = otsr.orexcuse
SELECT RIID, CID,.. .FROM(.. .) REI
LEFT JOIN (SELECT OTS.RIID,
SUM(OTS.ORMONEY) ORMONEY,
OTS.OREXCUSE,
OTS.ORTYPE
FROM (SELECT O.RIID,
O.ORTYPE,
RT.RTNAME,
O.OREXCUSE,
O.ORMONEY
FROM OTHERREIMBURSE O
LEFT JOIN REIMBURSETYPE RT ON RT.RTNAME = O.ORTYPE) OTS
GROUP BY OTS.RIID, OTS.OREXCUSE, OTS.ORTYPE) OTSR ON REI.RIID =
OTS.RIID
AND REI.CID =
&