returnDbConnection.Query<Material>("select max(Id) ID,'' Factory,CustomerPartCode,MaterialDesc,EstimateTypeDesc,EstimateType from Set_material where CustomerPartCode is not null group by CustomerPartCode, MaterialDesc, EstimateTypeDesc, EstimateType ").ToList();
" LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" ) temp1\n"+
" ) temp1\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode";
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceListBJ WHERE Version = '202110' and Type=20 ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode";
" LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" ) temp1\n"+
" ) temp1\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceListBJ WHERE Version = '202110' and Type=20 ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode";
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) and Type=10) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode";
" LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" ) temp1\n"+
" ) 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";
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceListBJ WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) and Type=20 ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode";
" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n"+
" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n"+
" AND temp1.SAP编码= temp3.MaterialCode\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 OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceListBJ WHERE Version = '202110' and Type=20 ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n"+
" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n"+
" LEFT JOIN ( SELECT * FROM set_backQty ) temp3 ON temp1.采购订单号 = temp3.Code \n"+
" AND temp1.SAP编码= temp3.MaterialCode\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 OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceListBJ WHERE Version = '202110' and Type=20 ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n"+