"selec a.单据号,a.客户编码,a.客户名称,数量 as 列表数量,辅助数量 as 明细数量,金额 as 列表金额,明细金额 from {销售单} As a full join (Selec 单据号,客户编码,sum(辅助数量) As 辅助数量,sum(金额) As 明细金额 from {销售单明细} where "& filter &" group by 单据号,客户编码) As b on a.单据号 = b.单据号 where (a.数量<> b.辅助数量 Or a.金额<>b.明细金额) And a.单据状态='已审核' and " & filter
或者
"selec a.单据号,a.客户编码,a.客户名称,数量 as 列表数量,辅助数量 as 明细数量,金额 as 列表金额,明细金额 from (select * from {销售单} where 单据状态='已审核' and " & filter & ") As a full join (Selec 单据号,客户编码,sum(辅助数量) As 辅助数量,sum(金额) As 明细金额 from {销售单明细} where "& filter &" group by 单据号,客户编码) As b on a.单据号 = b.单据号 where (a.数量<> b.辅助数量 Or a.金额<>b.明细金额)"