在 Microsoft Access 中对行进行排序
我需要的是按照行中指定的顺序重新排列表中的列。
因此,如果我有:
one four two three
1 4 2 3
我怎样才能得到:
one two three four
1 2 3 4
我已经考虑创建一个新表,并分别查看每个元素及其邻居,并将最低元素复制到新表中,并在整个表中重复,直到所有元素都移动为止。
这个方法行得通吗? 如果是这样,我是否有必要在 VBA 中进行(我对此没有太多经验)? 或者SQL中有什么方法吗?
感谢您的任何帮助。
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SQL 基于数据的关系模型。关系模型的原则之一是列的顺序是没有意义的。
但如果您绝对必须在 Access 中执行此操作,请使用查询、表单或报表。您可以按照您喜欢的任何顺序将列放置在这三者中的任何一个中,并且它根本不会影响基表。
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.
如果项目的顺序很重要,则它们通常存储在行中,而不是列中,例如,具有以下字段的表:
StudentID、ExamID、ExamDate
可以按 StudentID 和 ExamDate 排序以给出有用的顺序,无论输入顺序如何。此外,交叉表查询将允许在列中呈现数据。如果列的顺序变得很重要,则几乎总是表明表设计中存在错误。您可能希望阅读关系数据库设计基础,Paul Litwin,2003
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