" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle WHERE VERSION < '{0}' GROUP BY kanban, MaterialCode ) temp1\n"+
" INNER JOIN ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle WHERE WMSActualGoodsDate < '{2}' GROUP BY KanBan, MaterialCode ) temp2 ON temp1.Kanban = temp2.KanBan \n"+
" AND temp1.MaterialCode = temp2.KanBan \n"+
" (\n"+
" ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle WHERE WMSActualGoodsDate < '{2}' GROUP BY KanBan, MaterialCode ) temp1\n"+
" LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle WHERE VERSION < '{0}' GROUP BY kanban, MaterialCode ) temp2 ON temp1.Kanban = temp2.KanBan \n"+
" AND temp1.MaterialCode = temp2.KanBan \n"+
" ) \n"+
" ) C ON A.Kanban = C.Kanban \n"+
" AND A.MaterialCode = C.MaterialCode\n"+
" LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE VERSION = '{0}' GROUP BY materialcode ) d ON A.MaterialCode = d.MaterialCode \n"+
" WHERE\n"+
" A.VERSION = '{0}' {1}\n"+
" A.VERSION = '{0}' {1}\n"+
" ) TEMP1\n"+
" LEFT JOIN set_backQty temp3 ON temp1.Kanban = temp3.Code \n"+
" AND temp1.SapMaterialCode = temp3.MaterialCode\n"+
" LEFT JOIN ( SELECT Price, --定价\n"+
" MaterialCode --厂内物料号\n"+
" FROM Set_PriceList WHERE VERSION = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode \n"+
//" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle WHERE VERSION < '{0}' GROUP BY kanban, MaterialCode ) temp1\n" +
//" INNER JOIN ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle WHERE WMSActualGoodsDate < '{2}' GROUP BY KanBan, MaterialCode ) temp2 ON temp1.Kanban = temp2.KanBan \n" +
//" AND temp1.MaterialCode = temp2.KanBan \n" +
//" ) C ON A.Kanban = C.Kanban \n" +
//" AND A.MaterialCode = C.MaterialCode\n" +
//" LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE VERSION = '{0}' GROUP BY materialcode ) d ON A.MaterialCode = d.MaterialCode \n" +
//" WHERE\n" +
//" A.VERSION = '{0}' {1}\n" +
//" ) TEMP1\n" +
//" LEFT JOIN ( SELECT Price, --定价\n" +
//" MaterialCode --厂内物料号\n" +
//" FROM Set_PriceList WHERE VERSION = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode \n" +