" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' GROUP BY MaterialCode, Version, PurchasePriceNoTax ) AS a\n"+
" FROM\n"+
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n"+
" Set_WMSSparePart a\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 PurchaseOrderNo, Version, PurchaseOrderNoText, PurchasePriceNoTax, InvoicedQty, AmountNoTax FROM Set_SparePart WHERE Version = '{0}' ) b ON a.PurchaseOrderNo = b.PurchaseOrderNo\n"+
" WHERE\n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" ( a.Version = '{0}' ) \n"+
" WHERE\n"+
" ) AS temp1\n"+
" b.PurchaseOrderNo IS NULL \n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode";
" ) AS temp1\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n"+
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS a\n"+
" LEFT JOIN ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' ) AS b ON 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.MaterialCode IS NULL ) \n"+
" ) AS temp1\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode";