Update one of 2 duplicates in an sql server database table

前端 未结 11 1213
长发绾君心
长发绾君心 2020-12-05 00:48

I have got a table that got a column with duplicate values. I would like to update one of a 2 duplicate values so for example row1 = tom and row2 = tom

11条回答
  •  醉梦人生
    2020-12-05 01:25

    try this

    with test as 
    (
       select ROW_NUMBER() over (order by salary)rr, salary , emp_no 
       from salary
    )update test set emp_no=10007 where emp_no='10002'  and rr=3
    

提交回复
热议问题