I have table with
id name 1 aa 1 bb 2 ff 3 df
I want to check if value is repeated in column "id" then assign the "name" value to next matching ids row Expected:
id name 1 aa 1 aa 2 ff 3 df
Can any one suggest how this can be achieved?
WITH cte AS (SELECT *, MIN(name) OVER (PARTITION BY id ORDER BY name ASC) rn FROM test) UPDATE cte SET name=rn
This will work on the basis of the "lower" letters (IE 'A') will overwrite "higher" letters (IE 'B'), as you have not indicated any preference for how to handle this ordering.