Update one of 2 duplicates in an sql server database table

前端 未结 11 1237
长发绾君心
长发绾君心 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:07

    Try this mate

    UPDATE Table1 
    SET Column1 = column1 +'a'   
    WHERE exists(
            select row 
            from (
                SELECT 
                    Column1 , 
                    Row_Number() over(Partition by Column1 order by Column1) as row 
                FROM Clients
            ) as subquery 
            where subquery.row = 2
        )
    

提交回复
热议问题