SELECT w.ZDBH,
w.HEATINGANDAIRCONDITIONERID,
w.ZDMC,
w.CZBH,
w.CZMC,
w.CNXS,
w.ND,
w.KTJF,
w.KTJFMJ,
w.KTZY,
w.KTCS,
w.KTJ,
h.hMJ HCOUNT,
a.hmj KCOUNT
FROM TB_FDN_HEATINGAIRCONDITIONER w
LEFT JOIN (select HEATINGANDAIRCONDITIONERID,sum(MJ) hmj from TB_FDN_HEATINGHOUSE where TB_FDN_HEATINGHOUSE.HEATINGTYPE=0 group by HEATINGANDAIRCONDITIONERID) h ON (w.HEATINGANDAIRCONDITIONERID=h.HEATINGANDAIRCONDITIONERID)
LEFT JOIN (select HEATINGANDAIRCONDITIONERID,sum(MJ) hmj from TB_FDN_HEATINGHOUSE where TB_FDN_HEATINGHOUSE.HEATINGTYPE=1 group by HEATINGANDAIRCONDITIONERID) a ON (w.HEATINGANDAIRCONDITIONERID=a.HEATINGANDAIRCONDITIONERID)