How to 'resequence' a column value with an update statement...
Hi:
Would anyone please give me some help on this? I have a table, it contains several columns, the most important are these:
plant - char(3)
item - char(10)
supplier - char(10)
part - char(10)
rank - number
My question is this: how can I write an update statement that would update the field 'rank' in a sequential manner? Take this example (the columns would match the layout above).
What I want is to be able to resequence the last field (rank) starting with the value 1 and clearing up any 'gaps' in the process, incrementing by the value of 1. The end result should look like this:
Can this be done with a SQL update statement? The rows being updated may or may not be 'in sequence' by rank. That is why I want to be able to resequence the ranking, starting at 1 and incrementing by 1.
What I am asking is given a plant/item, how can I resequence the 'rank' column with an update statement. Looks like this can't be done. If I do somethingl like:
update tablexxx
set rank = rank + 1
where plant = '001'
and item = 'item2'
Then I would get the current value plus 1. That is not good because my goal is to have the rows look like this:
Bookmarks