DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Sorting strings in Alphanumeric order

  1. #1
    Join Date
    Dec 2004
    Posts
    1

    Exclamation Sorting strings in Alphanumeric order

    Hai

    Is there a way to sort a string column in ascending order with aplha first and then numeric(Dictionary order).
    For example,

    If the column productid has values A100,2030,B223 and 1002,
    the sort order must be
    A100
    B223
    1002
    2030

    Normal ascending order in SQl query gives sorting as 1002, 2030, A100 and B223.

    Please help

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Use "ALTER SESSION SET NLS_SORT = ...." to set the linguistic sorting order. By default it is set to BINARY which colates the digits before the alpha characters.

    You can use "ALTER SESSION SET NLS_SORT = WEST_EUROPEAN" (as an example) to get alpha characters listed before the numeric characters.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width