You should use the sub-query as follows:
SELECT T.*,
row_number() Over (partition by material, plant order by RMSESum ASC) as Ranking
FROM
(Select material, plant, fiscper, dmd_final_Fcst, sum_final_dmd_qty,
Sum(RMSE) over (partition by material, plant) as RMSESum,
Power(Fcst_er,2) As Sq_er,
dmd_final_fcst - sum_final_dmd_qty As Fcst_Er,
Sqrt(MSE) As RMSE,
Avg(Sq_er) as MSE
from PRD_DWH_PURCHASING.HistoricalForecastVal
group by 1,2,3,4,5) t;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…