Feb 27, 2003 #1 vincer Programmer Mar 12, 2002 45 GB if i have a statement such as select * from customers where custid in (5,10,7,3) is there any way to get the result set ordered in the same order as the IN list is specified? Thanks Vince
if i have a statement such as select * from customers where custid in (5,10,7,3) is there any way to get the result set ordered in the same order as the IN list is specified? Thanks Vince
Feb 27, 2003 1 #2 JamesLean Programmer Dec 13, 2002 3,059 GB Code: SELECT * FROM customers WHERE custid IN (5, 10, 7, 3) ORDER BY CASE custid WHEN 5 THEN 1 WHEN 10 THEN 2 WHEN 7 THEN 3 WHEN 3 THEN 4 END I know your query was only an example but hopefully you get the idea. --James Upvote 0 Downvote
Code: SELECT * FROM customers WHERE custid IN (5, 10, 7, 3) ORDER BY CASE custid WHEN 5 THEN 1 WHEN 10 THEN 2 WHEN 7 THEN 3 WHEN 3 THEN 4 END I know your query was only an example but hopefully you get the idea. --James
Feb 27, 2003 Thread starter #3 vincer Programmer Mar 12, 2002 45 GB Thanks, I can build this case statement up with my app as the list will only have upto 10 elements Upvote 0 Downvote