Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2013
    Posts
    1

    Unanswered: Sort issue on oracle

    Hi Everyone,

    I have a data as shown below in a column,

    1
    1-
    1+
    A
    A-
    A+
    10-
    10
    10+
    B
    B-
    B+
    2
    2-
    2+

    I want this data to be displayed either in ascending order or by decending order,

    I tried

    SELECT * from TEST ORDER BY 1 DESC;

    But its giving wrong results as

    A-
    A+
    A
    2-
    2+
    2
    10-
    10+
    1-
    1+

    etc

  2. #2
    Join Date
    Mar 2007
    Posts
    623
    Hi,

    as data is represented by strings, they are correctly ordered by lexical order based on ASCII character table. Its rules are described e.g. here: http://www.thefreedictionary.com/lexical+order
    the arrangement of a set of items in accordance with a recursive algorithm, such as the entries in a dictionary whose order depends on their first letter unless these are the same in which case it is the second which decides, and so on
    If you want different one, firstly define all its rules. Then it will be quite easy to implement them.

Posting Permissions

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