Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Query to Re-arrange Tables

Status
Not open for further replies.

marklaw01

Technical User
Apr 4, 2003
4
0
0
CR
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.
 
You will just need to use the Order By syntax at the end of your query...i.e.

"Select * From TABLE Where Row# > 0 Order By Row#, Sequence;"
 
I don't see how "Order By" will work. Sequence# = NextStep#. In the second table the sequence# is not in numerical order. If I am missing something then perhaps you can send the SQL code that will select from table 1 and output table 2.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top