Imagine a table with [ID, Name, Position, Price]
Currently the table has ALL the records with Position=0 and each record has a different price value.
What is the quickest way to update that Position and set its value unique and based on the Price, where the record with the lowest price is Position=1, the second lowest is Position=2 …and so on?
You could use
row_numberto number rows. A subquery is required to refer to the row number by alias:Working example at SE Data.