Results 1 to 7 of 7

Thread: order by

  1. #1
    Join Date
    Mar 2004
    Posts
    50

    Arrow Unanswered: order by

    Hi,
    I want to do something like following. Plz suggest

    select b, a
    from tbl_x x
    where x.b in (1,5,3,6,4,8,6,9)

    i want tht the result shud be ordered by in the order of values in in "in" clause..
    i.e. the order of results shud be 1,5,3,6,4,8,6,9.

    Plz advise.

    Thnx
    Ishan

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    There was a recent "discussion" of this very topic on the ORACLE-L list
    The archives can be seen at
    http://www.freelists.org/archives/oracle-l/
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Mar 2004
    Location
    Colorado
    Posts
    49
    This is ugly

    select 1, b, a
    from tbl_x x
    where x.b = 1
    union
    select 2, b, a
    from tbl_x x
    where x.b = 5
    ...
    union
    select 8, b, a
    from tbl_x x
    where x.b = 9
    order by 1

  4. #4
    Join Date
    Mar 2004
    Posts
    50
    this isnt really a good idea..

    Thanks
    Ishan

  5. #5
    Join Date
    Mar 2004
    Posts
    50
    Quote Originally Posted by anacedent
    There was a recent "discussion" of this very topic on the ORACLE-L list
    The archives can be seen at
    http://www.freelists.org/archives/oracle-l/
    Anacedent,
    I have been trying to hunt the url tht u gave me for the discussion, but am unable to find the required thread.
    Could you please tell the subject of the thread so that i can search for it.. and/or approx date of the thread..

    Thnx
    Ishan

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    The discussion happened "recently".
    IIRC, it was last week or at least not earlier than the last week of April.
    I did not really care about the topic, so I don't really recall any details.
    If you are desparate, join the list, post your question and
    ask how to search the archives for some clues.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  7. #7
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    How about:

    select b, a
    from tbl_x x
    where x.b in (1,5,3,6,4,8,6,9)
    order by decode(x.b, 1,1, 5,2, 3,3, 6,4, 4,5, 8,6, 6,7, 9,8);

Posting Permissions

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