stringsqlString=" select "+string.Format(" {0} as Version , ",version)+" r1.ErpMaterialCode, r2.Price, r1.SumPrice , r1.MaterialDesc, (isnull(r2.Price,0)-isnull(r1.SumPrice,0)) as diffPrice from \n"+
"( select ErpMaterialCode, MaterialDesc, SUM(Price) as SumPrice from(\n"+
"select a.ErpMaterialCode, b.SettlementPartCode, a.MaterialDesc, (a.Qty * b.Price) as Price from\n"+
"(SELECT ErpMaterialCode, MaterialDesc, SettleMaterialCode, Qty, Version ,CustomerCode \n"+
" where mdetail.Version='{0}' and mdetail.CustomerCode='{1}' \n"+
") a \n"+
"inner join Set_settlement_part b on a.Version = b.Version and a.SettleMaterialCode = b.SettlementPartCode and a.CustomerCode = b.CustomerCode) temp group by ErpMaterialCode, MaterialDesc) r1 left join set_pricelist r2 "+
" on r2.MaterialCode=r1.ErpMaterialCode and r2.Version='{0}'\n";
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) b ON a.SettleMaterialCode = b.MaterialCode \n"+
" ) temp1 \n"+
" GROUP BY\n"+
" ErpMaterialCode \n"+
" ) t1\n"+
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) t2 ON t1.ErpMaterialCode = t2.MaterialCode\n"+
" LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) t3 ON t1.ErpMaterialCode = t3.MaterialCode";