OrderBy question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ndoggy020
    New Member
    • Sep 2006
    • 11

    OrderBy question

    Hello.

    I am trying to sort my results via the account number field.

    I am sorting in descending order but the kicker is, the account numbers can contain letters as well. For example:

    123456ABC1

    What I am seeing in my results is this for example: (remember in DESC order)

    123456ABC
    1222
    111234DEF

    I dont undestand how that '1222' could be right there. Any ideas on what is wrong or how to correct this?

    Thanks
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Try this

    [code=oracle]

    SELECT * FROM table_name ORDER BY REPLACE(TRANSLA TE(UPPER(column _name),'ABCDEFG HIJKLMNOPQRSTUV WXYZ',' '),' ','')

    [/code]

    Comment

    • ndoggy020
      New Member
      • Sep 2006
      • 11

      #3
      It did not work. Please help.

      Thanks for the try.

      Comment

      • ndoggy020
        New Member
        • Sep 2006
        • 11

        #4
        I think my problem is that this field I am trying to order by is a varchar and not truly numeric. This could be the cause.

        Comment

        • amitpatel66
          Recognized Expert Top Contributor
          • Mar 2007
          • 2358

          #5
          Originally posted by ndoggy020
          I think my problem is that this field I am trying to order by is a varchar and not truly numeric. This could be the cause.
          Try this:

          [code=oracle]

          SELECT col1,col2,col3 FROM
          (SELECT col1,col2,col3, REPLACE(TRANSLA TE(UPPER(column _name),'ABCDEFG HIJKL MNOPQRSTUVWXYZ' ,' '),' ','') num FROM table_name) ORDER BY num

          [/code]

          Comment

          Working...