Tandem Posted August 14, 2006 Share Posted August 14, 2006 If i want to order some query results by a factor that has no sort of reasonable order, but i know which order they should be in e.g1. Dog2. Cat3. Lionor something like that, how would i go about doing that?If you need more information or i don't make sense, please ask/say.Thanks in advance for any help. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 14, 2006 Share Posted August 14, 2006 You could use a SQL CASE statement[code]SELECT animal FROM mytableORDER BY CASE WHEN animal='Dog' THEN 1 WHEN animal='Cat' THEN 2 WHEN animal='Lion' THEN 3 ELSE 99END[/code] Quote Link to comment Share on other sites More sharing options...
Tandem Posted August 14, 2006 Author Share Posted August 14, 2006 Awesome, thats exactly what i need, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.