sql将表中的某个字段进行排序

 

1. update tempTable set field1 = rownum from(
        select field1, ROW_NUMBER() over(order by fieldId) rownum from table1
    ) tempTable

2. with tempTable as (
        select field1, ROW_NUMBER() over(order by fieldId) rownum from table1
    )
    update tempTable set field1 = rownum

 效果图

原文地址:https://www.cnblogs.com/w-ang/p/6037596.html