Home » SQL & PL/SQL » SQL & PL/SQL » order by given order
order by given order [message #430914] Fri, 13 November 2009 02:02 Go to next message
123soleil
Messages: 35
Registered: July 2006
Member
I feel stupid asking this question but could not find an answer anywhere.

I have the following statement:

select * from clients where id in (5,3,6,4,8,9,1)

I need to return the results in exactly that order. How do I do this?

Many thanks
Re: order by given order [message #430916 is a reply to message #430914] Fri, 13 November 2009 02:23 Go to previous messageGo to next message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
order by decode(id, 5,1, 3,2, 6,3, 4,4, 8,5, 9,6, 1,7)

Regards
Michel
Re: order by given order [message #430921 is a reply to message #430914] Fri, 13 November 2009 02:34 Go to previous message
123soleil
Messages: 35
Registered: July 2006
Member
thanks
Previous Topic: To convert a -ve number to Hexadecimal
Next Topic: Usage of INSTR Function
Goto Forum:
  


Current Time: Fri Dec 02 14:30:49 CST 2016

Total time taken to generate the page: 0.18524 seconds