简体   繁体   中英

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. 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. 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. It just seems to break ordering when there are 4 or more digits on any side of the decimal. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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