开发者

Sorting across a row in Microsoft Access

What I need is to re-arrange the columns in a table by the order specified in a row.

So if I had:

one    four    two  开发者_如何学JAVA  three
 1       4      2       3

How could I get:

one    two    three    four
 1      2       3       4

I have considered creating a new table and looking at each of the elements and its neighbor individually and copying the lowest element to the new table and repeating throughout the table until all the elements have moved.

Would this method work? If so is it necessary I do it in VBA (I don't have much experience with this)? Or is there a method in SQL?

Thanks for any help.


SQL is based on the relational model of data. One of the principles of the relational model is that the order of columns is meaningless.

But if you absolutely have to do this in Access, use a query, a form, or a report. You can put the columns in any order you like in any of these three, and it won't affect the base table at all.


If the order of items is important, they are typically stored in rows, not columns, for example, a table with the following fields : StudentID, ExamID, ExamDate can be sorted by StudentID and ExamDate to give a useful order, regardless of the order of entry. Furthermore, a crosstab query will allow the presentation of data in columns.

If the order of columns has become important, it is nearly always an indication of an error in the table design. You may wish to read Fundamentals of Relational Database Design, Paul Litwin, 2003

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜