select A.*,B.*,C.money
from A
inner join B
on A.ID = B.ID
left join
(
select D.ID , SUM(D.money) as money
from D
group by D.ID
) C
on B.ID = C.ID
where A.ID = XXX
这样可以分组查出来统计sum出来的金额
select A.*,B.*,C.money
from A
inner join B
on A.ID = B.ID
left join
(
select D.ID , SUM(D.money) as money
from D
group by D.ID
) C
on B.ID = C.ID
where A.ID = XXX
这样可以分组查出来统计sum出来的金额