I have database with a table called orders. The structure is below
Index, OrderIndex, OrderNo
111, 1
112 , 1
113 , 1
114 , 2
115 , 3
116 , 3
I want a query that will loop thorugh the database and make the result
Index, OrderIndex, OrderNo
111, 1, 1
112, 1, 2
113, 1, 3
114, 2, 1
115, 3, 1
116, 3, 2
Im trying to change the OrderNo based on the OrderIndex.
Is there a way to do this purely using sql? If possible please help.