I am trying to do some SQL working with Oracle
I have a table that contains text data, and an order list of numbers of how that text should appear, 1-27.
So:
Bonjour | 1
mon nom | 2
Jean P. | 3
Hello J | 4
Je suis | 5
is John | 6
Now I have to reorder the list numbers:
5 to number 2, and move 2 to 3, 3 to 4, 4 to 5, BUT NOT 5 to 6 or 6 to anything. Remember, this is a list to number 27.
So I'll have:
Bonjour | 1
mon nom | 2
Jean P. | 3
Hello J | 4
My name | 5
is John | 6
Does anyone know of a good way to go about doing this?
Something like:
The
elsepart in the case is not stricly necessary. But in case you forget the where clause it prevent accidental wrong updates.Here is an SQLFiddle example: http://sqlfiddle.com/#!4/52d50/1