How can I get numbers to ascend and descend in order properly?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Right now, when I tell it to sort ascending, it orders them by the first
digit, not by the entire value, (ie 12, 19, 29, 7, 9) where it shoud be (7,
9, 12, 19, 29).
 
kyle19 said:
Right now, when I tell it to sort ascending, it orders them by the
first digit, not by the entire value, (ie 12, 19, 29, 7, 9) where it
shoud be (7, 9, 12, 19, 29).

When you look a them a number 1 and a text 1 both look the same, but
they are not the same. If you want number to sort according to their
numeric value, you must make sure they are in a number field not a text
field.

Generally you can switch field types and it will convert, but if you
have any thing like 12 25 with a space, it will have problems as will things
line 12a with a text character.
 
If you don't want to change the data type for the field, you could write a
query with a field that converts the "text number" into a "number number"
and sort on that field. Try something like:

SELECT CLng([Field1]) AS TheNumber
FROM Table1
ORDER BY CLng([Field1]);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top