" 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' ) \n"+
" AND a.Version= '{0}' {1} \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";
" 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"+
var_sql=string.Format(str,version,condition);
" LEFT JOIN (\n"+
" SELECT SUM\n"+
" ( Amt ) / SUM ( Qty ) AS 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"+