" LEFT JOIN ( SELECT SUM( QTY ) Qty, MaterialCode FROM Set_settle WHERE version = '{0}' GROUP BY MaterialCode ) c ON b.MaterialCode = c.MaterialCode\n"+
" LEFT JOIN ( SELECT SUM( QTY ) qty, MaterialCode FROM Set_KanbanSettle WHERE version = '{0}' GROUP BY MaterialCode ) d ON b.MaterialCode = d.MaterialCode\n"+
" LEFT JOIN ( SELECT * FROM Set_ScrapClaims WHERE version = '{0}' ) e ON b.MaterialCode = e.MaterialCode\n"+
" LEFT JOIN ( SELECT * FROM Set_PriceList WHERE version = '{0}' ) f ON b.MaterialCode = f.MaterialCode";
stringsqlString="select "+string.Format(" {0} as Version ,",version)+"a.MaterialCode,isnull(b.qty,0) InvoiceQty,isnull(c.qty,0) SettleQty, (isnull(b.qty,0)-isnull(c.qty,0)) as DiffQty from (\n"+
" select distinct MaterialCode from( \n"+
"select distinct MaterialCode from Set_Invoice {0}\n"+
return_list;
"union all\n"+
"select distinct MaterialCode from {1} {0}\n"+
") temp \n"+
") as a\n"+
"left join\n"+
"\n"+
"(select SUM(QTY) qty,MaterialCode from Set_Invoice {0} GROUP BY MaterialCode) b on a.MaterialCode=b.MaterialCode\n"+
"\n"+
"left join\n"+
"(select SUM(QTY) qty,MaterialCode from {1} {0} GROUP BY MaterialCode) c on a.MaterialCode=c.MaterialCode";