I have a table of values like this:
CREATE TABLE
(
Name1 VARCHAR (50),
Name2 VARCHAR (50),
Sequence INT
)
In this table, I have rows like this
'Bob', 'Jones', 1
'James','Ant', 2
I want the best thing to do is to perform an UPDATE (UPDATE SET) sequence based on the order of the Name2 column name, so when re-sequencing the values are as follows:
'James','Ant', 1
'Bob', 'Jones', 2
I am sure that this can be done using the ROW_NUMBER OVER () CTE style, but I'm not sure about the exact syntax.
source
share