" LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" \n"+
" WHERE\n"+
" a.Version= '{0}' \n"+
" AND a.StorageLocationDesc NOT LIKE '%备品%'\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\n"+
" ( SELECT Price, SUM ( Qty ) Qty, MaterialCode, Version FROM Set_BT_Car_Platform GROUP BY MaterialCode, price, Version ) A\n"+
" (\n"+
" INNER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" SELECT SUM\n"+
" ( Qty ) Qty,\n"+
" MaterialCode,\n"+
" StorageLocation,\n"+
" StorageLocationDesc,\n"+
" Version \n"+
" FROM\n"+
" Set_BT_Car_Platform \n"+
" WHERE\n"+
" WHERE\n"+
" A.Version= '{0}' \n"+
" version = '{0}' \n"+
" AND StorageLocationDesc NOT LIKE '%备品%' \n"+
" GROUP BY\n"+
" MaterialCode,\n"+
" StorageLocation,\n"+
" StorageLocationDesc,\n"+
" Version \n"+
" ) A\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_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS temp2 ON temp1.Sap编码 = temp2.MaterialCode\n"+
// " INNER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \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 JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" \n"+
" WHERE\n"+
" a.Version= '{0}' \n"+
" AND a.StorageLocationDesc LIKE '%备品%'\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\n"+
// " LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \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";
// var _sql = string.Format(str, version, condition);
// var _query = DbConnection.Query<HQCarSettledDetailDiff>(_sql, null, null, true, 1200, null);
" LEFT JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \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\n"+
" LEFT JOIN (\n"+
" SELECT SUM\n"+
" ( Amt ) / SUM ( Qty ) AS Price,\n"+
" MaterialCode,\n"+
" Version \n"+
" FROM\n"+
" Set_BT_Car_Platform \n"+
" WHERE\n"+
" version = '{0}' \n"+
" AND StorageLocationDesc LIKE '%备品%' \n"+
" GROUP BY\n"+
" MaterialCode,\n"+
" Version \n"+
" ) AS TEMP3 ON temp1.[结算物料号] = temp3.MaterialCode";
" INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n"+
" INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n"+
" AND a.MaterialCode = b.MaterialCode\n"+
" AND a.MaterialCode = b.MaterialCode\n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" WHERE\n"+
" WHERE\n"+
" ( a.HQHKanBan <> 'BJ' ) \n"+
" ( a.HQHKanBan <> 'BJ' AND a.HQHKanBan IS NOT NULL ) \n"+
" AND a.Version= '{0}' \n"+
" AND a.Version= '{0}' \n"+
" ) AS temp1\n"+
" ) AS temp1\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\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\n"+
" LEFT JOIN (\n"+
" LEFT JOIN (\n"+
" SELECT SUM\n"+
" SELECT\n"+
" ( Amt ) / SUM ( Qty ) AS Price,\n"+
" ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n"+
// " INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
// " AND a.MaterialCode = b.MaterialCode\n" +
// " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
// " WHERE\n" +
// " ( a.HQHKanBan <> 'BJ' AND a.HQHKanBan IS NOT NULL ) \n" +
// " AND a.Version= '{0}' \n" +
// " ) AS temp1\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\n" +
// " LEFT JOIN (\n" +
// " SELECT\n" +
// " ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" +
// " HQHKanBan,\n" +
// " MaterialCode,\n" +
// " Version \n" +
// " FROM\n" +
// " Set_HQ_H_Platform \n" +
// " WHERE\n" +
// " HQHKanBan <> 'BJ' \n" +
// " AND Version = '{0}' \n" +
// " GROUP BY\n" +
// " HQHKanBan,\n" +
// " MaterialCode,\n" +
// " Version \n" +
// " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
// " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
// " WHERE\n" +
// " a.Version= '{0}' \n" +
// " ) AS temp1\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\n" +
// " LEFT JOIN (\n" +
// " SELECT\n" +
// " ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" +
// " MaterialCode,\n" +
// " Version \n" +
// " FROM\n" +
// " Set_HQ_H_Platform \n" +
// " WHERE\n" +
// " HQHKanBan IS NULL \n" +
// " AND Version = '{0}' \n" +
// " GROUP BY\n" +
// " MaterialCode,\n" +
// " Version \n" +
// " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
" ( SELECT * FROM Set_HQ_H_Platform WHERE HQHKanBan <> 'BJ' AND Version = '{0}' ) AS a\n"+
" LEFT OUTER JOIN Set_HQ_H_Kanban AS b ON a.HQHKanBan = b.Kanban \n"+
" LEFT OUTER JOIN Set_HQ_H_Kanban AS b ON a.HQHKanBan = b.Kanban \n"+
" AND a.MaterialCode = b.MaterialCode\n"+
" AND a.MaterialCode = b.MaterialCode\n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" WHERE\n"+
" WHERE\n"+
" a.HQHKanBan <>'BJ' AND a.Version= '{0}' \n"+
" b.Kanban IS NULL \n"+
" AND b.MaterialCode IS NULL \n"+
" ) AS temp1\n"+
" ) AS temp1\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 WHERE temp1.[交货单号] is null ";
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode \n"+
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n"+
" WHERE\n"+
" a.Version= '{0}' \n"+
" ) AS temp1\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\n"+
" LEFT JOIN (\n"+
" SELECT\n"+
" ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n"+
" MaterialCode,\n"+
" Version \n"+
" FROM\n"+
" Set_HQ_H_Platform \n"+
" WHERE\n"+
" HQHKanBan IS NULL \n"+
" AND Version = '{0}' \n"+
" GROUP BY\n"+
" MaterialCode,\n"+
" Version \n"+
" ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n"+
// " LEFT OUTER JOIN Set_HQ_H_Kanban AS b ON a.HQHKanBan = b.Kanban \n" +
// " AND a.MaterialCode = b.MaterialCode\n" +
// " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
// " WHERE\n" +
// " a.HQHKanBan <>'BJ' AND a.Version= '{0}' \n" +
// " ) AS temp1\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 WHERE temp1.[交货单号] is null ";