1

Is it possible to sort integers character by character?

So the list [110, 120, 10, 200, 20] would end up like this:

10,
110,
120,
20,
200
1
  • What have you tried? Which functions in the documentation did you rule out, and why? Commented Mar 15, 2012 at 16:46

2 Answers 2

4

If you cast the integer as a varchar or text value, and order by that cast, it should work.

ORDER BY CAST(myField AS CHAR)
Sign up to request clarification or add additional context in comments.

Comments

0
SELECT num
FROM your_table
ORDER BY CAST(num as CHAR)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.