select *,[累计实收]-[累计应收] AS 欠缴 from (SELECT DISTINCTROW 抄表记录.住户ID, Min(抄表记录.表示数) AS [min], Max(抄表记录.表示数) AS [max], 用户登记.zhhxm, max-min AS 累计用量, 累计用量*1.3 AS 累计应收
FROM 用户登记 INNER JOIN 抄表记录 ON 用户登记.zhhid = 抄表记录.住户ID
GROUP BY 抄表记录.住户ID, 用户登记.zhhxm) as a
left join (SELECT DISTINCTROW 发票明细.住户id, Sum(发票明细.收缴金额(元)) AS 累计实收, 用户登记.zhhxm
FROM 用户登记 INNER JOIN 发票明细 ON 用户登记.zhhid = 发票明细.住户id
GROUP BY 发票明细.住户id, 用户登记.zhhxm) as b
ON a.住户ID = b.住户id;