Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ORDER BY Help

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-08-27 : 09:46:43
Is it possible to order this query by the order in which the ids are
hard coded? So it displays in order 17, 9, 20 etc..

SELECT *
FROM tblLogins
WHERE id IN (17, 9, 20, 11, 25, 15, 8, 7)

mfemenel
Professor Frink

1421 Posts

Posted - 2004-08-27 : 09:51:17
select * from tbllogins
where id in(17,9,20,11,25,15,8,7)
order by case id when 17 then 1,when 9 then 2, when 20 then 3....... end

you might have to tweak that case statement a bit but you see where I'm going with it.

Mike
"oh, that monkey is going to pay"
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-08-27 : 09:53:00
Yes, I see where you are going. Thank you.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-08-27 : 13:48:43
It's order by day, here at sql team....

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=39159



Brett

8-)
Go to Top of Page
   

- Advertisement -