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

 效果图

 

posted @ 2016-11-07 09:47  W_ang  阅读(6204)  评论(0编辑  收藏  举报