" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1=1 {1} GROUP BY kanban, MaterialCode ) AS a\n"+
" LEFT OUTER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) AS b ON a.Kanban = b.HQHKanBan \n"+
" AND a.MaterialCode = b.MaterialCode\n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" WHERE\n"+
" b.HQHKanBan IS NULL \n"+
" AND b.MaterialCode IS NULL \n"+
" ) AS temp1\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n"+
" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n"+
" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1=1 {1} GROUP BY kanban, MaterialCode ) AS a\n"+
" INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode,Price FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode,Price ) AS b ON a.Kanban = b.HQHKanBan \n"+
" AND a.MaterialCode = b.MaterialCode\n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1 = 1 {1} GROUP BY kanban, MaterialCode ) temp1\n"+
" LEFT OUTER JOIN ( SELECT MaterialCode sap, CustomerPartCode FROM Set_material ) AS temp2 ON temp1.MaterialCode = temp2.CustomerPartCode \n"+
" ) a\n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode\n"+
" LEFT OUTER JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_WmsHQHKanbanOutPutDetial {0} GROUP BY Kanban, MaterialCode ) AS b ON a.Kanban = b.Kanban \n"+
" AND a.sap = b.MaterialCode \n"+
" WHERE\n"+
" a.Qty> b.Qty \n"+
" b.Kanban IS NULL \n"+
" AND b.MaterialCode IS NULL \n"+
" ) AS temp1\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n"+
" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n"+
//" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1=1 {1} GROUP BY kanban, MaterialCode ) AS a\n" +
//" LEFT OUTER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) AS b ON a.Kanban = b.HQHKanBan \n" +
//" AND a.MaterialCode = b.MaterialCode\n" +
//" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
//" WHERE\n" +
//" b.HQHKanBan IS NULL \n" +
//" AND b.MaterialCode IS NULL \n" +
//" ) AS temp1\n" +
//" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" +
//" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" +
//" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban WHERE 1=1 {1} GROUP BY kanban, MaterialCode ) AS a\n" +
//" INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode,Price FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode,Price ) AS b ON a.Kanban = b.HQHKanBan \n" +
//" AND a.MaterialCode = b.MaterialCode\n" +
//" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
//" WHERE\n" +
//" a.Qty> b.Qty \n" +
//" ) AS temp1\n" +
//" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" +
//" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" +
" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1=1 {1} GROUP BY MaterialCode, Kanban ) A\n"+
" INNER JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n"+
" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1=1 {1} GROUP BY MaterialCode, Kanban ) A\n"+
" LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, Extend1 AS MaterialCode FROM Set_WmsKanbanOutPutDetial {0} GROUP BY Kanban, Extend1 ) B ON A.Kanban = B.Kanban \n"+
" AND A.MaterialCode = B.MaterialCode\n"+
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n"+
" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n"+
" AND c.MaterialCode = tt.MaterialCode \n"+
" WHERE\n"+
" a.WMSDeliveryQty> B.Qty AND (a.WMSDeliveryQty-tt.Qty)!=B.Qty \n"+
" B.Kanban IS NULL \n"+
" AND B.MaterialCode IS NULL \n"+
" ) TEMP1\n"+
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n"+
" ) UNION2";
" ) UNION1\n"+
" LEFT JOIN temp_vwkanban UNION2 ON UNION1.Kanban= UNION2.[看板号] \n"+
" AND UNION1.CustomerPartCode= UNION2.[客户零件号] \n"+
" WHERE\n"+
" UNION2.[看板号] IS NULL \n"+
" AND UNION2.[客户零件号] IS NULL \n"+
" ) aaa \n"+
"WHERE\n"+
" aaa.CustomerPartCode NOT IN ( '30G839904A041', '80D867172KJ7' )";
//" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1 = 1 {1} GROUP BY MaterialCode, Kanban ) A\n" +
//" LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" +
//" AND A.MaterialCode = B.MaterialCode\n" +
//" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" +
//" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" +
//" AND c.MaterialCode = tt.MaterialCode \n" +
//" WHERE\n" +
//" B.Kanban IS NULL \n" +
//" AND B.MaterialCode IS NULL \n" +
//" ) TEMP1\n" +
//" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" +
//" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1 = 1 {1} GROUP BY MaterialCode, Kanban ) A\n" +
//" INNER JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle {0} GROUP BY Kanban, MaterialCode ) B ON A.Kanban = B.Kanban \n" +
//" AND A.MaterialCode = B.MaterialCode\n" +
//" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" +
//" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" +
//" AND c.MaterialCode = tt.MaterialCode \n" +
//" WHERE\n" +
//" a.WMSDeliveryQty> B.Qty \n" +
//" AND ( a.WMSDeliveryQty- tt.Qty ) != B.Qty \n" +
//" ) TEMP1\n" +
//" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" +
//" ) UNION2 \n" +
//" ) UNION12\n" +
//" LEFT JOIN temp_vwkanban UNION3 ON UNION12.Kanban= UNION3.[看板号] \n" +
//" AND UNION12.CustomerPartCode= UNION3.[客户零件号] \n" +
//" WHERE\n" +
//" UNION3.[看板号] IS NULL \n" +
//" AND UNION3.[客户零件号] IS NULL \n" +
//" ) aaa \n" +
//"WHERE\n" +
//" aaa.CustomerPartCode NOT IN ( '30G839904A041', '80D867172KJ7' ) ";
" LEFT JOIN ( SELECT SUM ( InvoicedQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo != 'NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n"+
" AND a.MaterialCode = b.MaterialCode\n"+
" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode\n"+
" LEFT JOIN ( SELECT SUM ( Qty ) Qty, OrderBillNum, MaterialCode FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 GROUP BY OrderBillNum, MaterialCode ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n"+
" AND a.SapCode = b.MaterialCode \n"+
" WHERE\n"+
" b.PurchaseOrderNo IS NULL \n"+
" b.OrderBillNum IS NULL \n"+
" AND b.MaterialCode IS NULL \n"+
" ) AS temp1\n"+
" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n"+
" AND temp1.SAP编码= temp3.MaterialCode\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n"+
" INNER JOIN ( SELECT SUM ( InvoicedQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo != 'NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n"+
" AND a.MaterialCode = b.MaterialCode\n"+
" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" WHERE\n"+
" a.ReceiptQty> b.ReceiptQty \n"+
" ) AS temp1\n"+
" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n"+
" AND temp1.SAP编码= temp3.MaterialCode\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n"+
//" LEFT JOIN ( SELECT SUM ( InvoicedQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo != 'NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" +
//" AND a.MaterialCode = b.MaterialCode\n" +
//" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" +
//" WHERE\n" +
//" b.PurchaseOrderNo IS NULL \n" +
//" AND b.MaterialCode IS NULL \n" +
//" ) AS temp1\n" +
//" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n" +
//" AND temp1.SAP编码= temp3.MaterialCode\n" +
//" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
//" INNER JOIN ( SELECT SUM ( InvoicedQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo != 'NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" +
//" AND a.MaterialCode = b.MaterialCode\n" +
//" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" +
//" WHERE\n" +
//" a.ReceiptQty> b.ReceiptQty \n" +
//" ) AS temp1\n" +
//" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n" +
//" AND temp1.SAP编码= temp3.MaterialCode\n" +
//" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +