select
a.房源id,
a.房源状态,
c.客户姓名,
c.手机号,
d.成交总价,
d.累计收款金额 from 房源 a
left join 定单表 b on a.房源id=b.房源id
left jion 客户表 c on b.客户id=c.客户id
left jion (select 定单id, sum(金额) as 累计收款金额 from 收款表 where 定单状态id=2 group by 定单id) d on b.定单id=d.定单id
select
a.房源id,
a.房源状态,
c.客户姓名,
c.手机号,
d.成交总价,
d.累计收款金额 from 房源 a
left join 定单表 b on a.房源id=b.房源id
left jion 客户表 c on b.客户id=c.客户id
left jion (select 定单id, sum(金额) as 累计收款金额 from 收款表 where 定单状态id=2 group by 定单id) d on b.定单id=d.定单id