Order by with numbers as text

  • I am trying to order some text with numbers and I can't get it to order correctly.  The problem is that when I try to order numbers such as 1.0, 1.1, 1.2, ..., 1.10 it gets ordered as 1.1, 1.10, 1.2, ...  I know why this is happening, but I can't think of any way to get around it.

  • If the number of dots in the column is less than or equal to 3 then use my solution else use David Burro's

    from here

     


    * Noel

  • One of the simplest ways is to change your data to a consistent format, eg:

    1.00, 1.01, 1.02, ..., 1.10

    would work.

    But if that doesn't suit, you need to write some SQL that will split out the n.m numbers into two integers, n and m, and then ORDER BY those.


  • Thanks for the link noeld.  That worked.

  • You are welcome!

     


    * Noel

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply