利用窗口函数进行排序字段更新

前一篇题目和解决办法

##利用窗口函数 更方便
update yxkj_eval_res_list t1,
	(select data_dt,org_no,INDEX_ID,INDEX_VAL,
		row_number() over(partition by data_dt,index_id order by index_id,index_val desc) as row_num
	from yxkj_eval_res_list) t2
set t1.grp_rank=t2.row_num
where t1.org_no=t2.org_no and t1.data_dt=t2.data_dt and t1.index_id=t2.index_id;

select data_dt,org_no,INDEX_ID,INDEX_VAL, grp_rank
	##row_number() over(partition by data_dt,index_id order by index_id,index_val desc) as row_num
from yxkj_eval_res_list order by data_dt,index_id,grp_rank;

窗口函数参考

你可能感兴趣的:(sql)