简体   繁体   English

Microsoft Access查询不会订购某些数字

[英]Microsoft Access query won't order certain numbers

I'm working on modifying an access application for my work. 我正在为自己的工作修改访问应用程序。 I'm generating a report that has categories denoted by integers 1-11. 我正在生成一个报告,该报告的类别由整数1-11表示。 Each subsection of these categories is a decimal such as 1.01,1.02,1.03, etc. When I generate the report each subsection from 1 to 9 is in ascending order, ie, 1.01 to 1.11 are in order. 这些类别的每个小节都是一个小数,例如1.01、1.02、1.03等。在生成报告时,从1到9的每个小节都是按升序排列的,即1.01到1.11是小数排列。 When it gets to 10 and 11, the categories are not in order, ie, 10.01, 10.04, 10.03, 10.02, etc. When I change the values of each subsection to 3 digits such as 10.1, 10.2, etc, they are sorted in correct order. 当它到达10和11时,类别不按顺序排列,即10.01、10.04、10.03、10.02等。当我将每个小节的值更改为3个数字(例如10.1、10.2等)时,它们将被排序正确的顺序。 It just seems to break ordering when there are 4 or more digits on any side of the decimal. 当小数点的任一侧有4个或更多数字时,似乎只是打破了顺序。 I'm not overly familiar with access or sql in general so I'm not sure on how to solve this problem other then editing the values of 10 and 11 to be 3 digits. 我对访问或sql不太熟悉,因此除了将10和11的值编辑为3位数字外,我不确定如何解决此问题。 The numbers for the subsection are stored in text field type. 小节的数字存储在文本字段类型中。 I've changed it to numbers and currency, neither of which resulted in a change in ordering. 我已将其更改为数字和货币,但两者均未导致顺序更改。 Does anyone have an idea why this is happening? 有谁知道为什么会这样? I apologize if I left out any critical information. 如果遗漏任何重要信息,我深表歉意。 Please let me know if there is any additional details I can provide. 如果还有其他详细信息,请告诉我。

当您将数字存储为字符串并要对其进行排序时,可以使用以下技巧:

order by len(category), category

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM