数据库
ID
1
2
31
2
3现在想把改为11、12、13、21、22、23怎么更新? 只有一个ID字段。

解决方案 »

  1.   

    什么数据库?
    oracle可以通过,将分组结果排序加上序号,然后再处理
    select row_number() over(partition by t.col order by t.col) n from t1 t
    order by t.col
      

  2.   

    弄个临时表把数据处理好再插回去
    select tt.n||tt.col from
    (select row_number() over(partition by t.col order by t.col) n,t.col from t1 t
    order by t.col) tt如果在原表基础上弄我也没想好怎么弄
      

  3.   

    分组,变成1,1,2,2,3,3.
    变量i=1
    然后判断第一条id+10 和下一条值吧  
    相同i=i+1;
    值变为id+i*10
    不同就有重新id+10
    大致这样  还要再整理下思路