项目上写的，供参考哈：SELECT T0."ItemCode" "物料编码",T0."ItemName" "物料名称",T2."DistNumber" "批次信息",T0."LocCode" "仓库",T4."BinCode" "库位",SUM(T3."Quantity") "数量",T2."MnfSerial" "批次属性1", T2."LotNumber" "批次属性2", CAST(T2."Notes" AS NVARCHAR(200)) "明细"FROM "OITL" T0 --批次交易主表INNER JOIN "ITL1" T1 ON T0."LogEntry" = T1."LogEntry" AND T0."ItemCode" = T1."ItemCode" AND ISNULL(T1."LogEntry",'') <>'' --批次交易明细表NNER JOIN "OBTN" T2 ON T1."ItemCode" = T2."ItemCode" AND T1."SysNumber" = T2."SysNumber" AND T1."MdAbsEntry" = T2."AbsEntry" --批次信息表LEFT JOIN "OBTL" T3 ON T2."AbsEntry" = T3."SnBMDAbs" AND T1."LogEntry" = T3."ITLEntry"INNER JOIN "OBIN" T4 ON T3."BinAbs" = T4."AbsEntry"INNER JOIN "OWHS" T5 ON T0."LocCode"= T5."WhsCode" WHERE T5."BinActivat"='Y'GROUP BY T0."ItemCode", T0."ItemName", T2."DistNumber",T0."LocCode", T4."BinCode", T2."MnfSerial", T2."LotNumber", CAST(T2."Notes" AS NVARCHAR(200)) HAVING SUM(T1."Quantity")<>0ORDER BY T0."ItemCode",T2."DistNumber" ;