Delete all but one duplicate record

后端 未结 5 1736
猫巷女王i
猫巷女王i 2020-12-04 18:23

I have a table that is supposed to keep a trace of visitors to a given profile (user id to user id pair). It turns out my SQL query was a bit off and is producing multiple p

5条回答
  •  独厮守ぢ
    2020-12-04 18:27

    This will work:

    With NewCTE
    AS
    (
    Select *, Row_number() over(partition by ID order by ID)as RowNumber from 
    table_name
    )
    Delete from NewCTE where RowNumber > 1
    

提交回复
热议问题