I want to use SQL to re-arrange the records in a table. In the first table below, the records are arranged in numerical step order. I want to re-arrange them in next step order.
If we start with the first table below, the query should generate the second table below. It does not matter if we need to add other columns to the output/query table. A sequence of queries is also O.K.
Row# Step# NextStep#
1 1 10
2 5 7
3 7 1004
4 10 52
5 52 5
6 1004
The re-arranged table should be
Row# sequence
1 1
2 10
3 52
4 5
5 7
6 1004
Thanks in advance.
If we start with the first table below, the query should generate the second table below. It does not matter if we need to add other columns to the output/query table. A sequence of queries is also O.K.
Row# Step# NextStep#
1 1 10
2 5 7
3 7 1004
4 10 52
5 52 5
6 1004
The re-arranged table should be
Row# sequence
1 1
2 10
3 52
4 5
5 7
6 1004
Thanks in advance.