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

Thread: Sorting/No Sorting

  1. #1
    Join Date
    Nov 2001
    Posts
    15
    I am trying to get the results of following SQL displayed in the order of selection as follows:

    select dept_code, dept_name from dept
    where dept_code IN ('B', 'C', 'A');

    Goal is to get the results in the order of dept_code listed in IN_CLAUSE:
    Dept_code Dept_name
    ---------------------------
    B DeptB
    C DeptC
    A DeptA

    Please help.

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    select dept_code, dept_name from dept
    where dept_code IN ('B', 'C', 'A');
    ORDER BY DECODE(dept_code, 'B', 1, 'C', 2, 'A',3)
    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