Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort By by given values 1

Status
Not open for further replies.

GoSooJJ

Programmer
Feb 24, 2001
76
US
Can I sort by given values? Assume that I have column call EMP_ID with range from 1 to 6 then I want to sort by this order (1,3,5,6,4,2). Is there such way to do it easily?
TIA
 
Code:
SELECT [i]columns[/i]
     , CASE emp_id
            WHEN 1 THEN 21
            WHEN 3 THEN 22
            WHEN 5 THEN 23
            WHEN 6 THEN 24
            WHEN 4 THEN 25
                   ELSE 26 END AS sort
  FROM daTable
ORDER 
    BY sort

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top