I have a table subscription with duplicate rows for each phone number
+----+------+-----+--- | id | phone | state | +----+------+-----+--- | 1 | 1234 | 1 | | 2 | 1234 | 1 | | 3 | 1234 | 1 | | 4 | 5678 | 1 | | 5 | 5678 | 1 | | 6 | 5678 | 1 | +----+------+-----+----
For each phone number I need to update the state column to -1 except for the last one, ordering by id DESC. So my table should become
+----+------+-----+--- | id | phone | state | +----+------+-----+--- | 1 | 1234 | -1 | | 2 | 1234 | -1 | | 3 | 1234 | 1 | | 4 | 5678 | -1 | | 5 | 5678 | -1 | | 6 | 5678 | 1 | +----+------+-----+----
I am new to oracle. Any ideas how this can be achieved? Am using oracle 11.2