I have a table with columns id, name, position, old_position
.
The column old_position
contains unique numbers that are used to define the order when making select. But the numbers are not consecutive(even if when ordered). E.g.
2, 12, 11, 14, 20, 35, 45, 28,
What I am trying to achieve is to populate the column position
with consecutive numbers starting from 1, but with the same order according to old_position, so when I order by position ASC
still I can get the same order of rows. Is there a way to do that ?
Thanks