Let’s say you have a Select Statement with a List of IDs in it’s “IN()” Part and want to get the Results in the same Order as the List of IDs.
You now could use the same “ORDER BY” you used when you got the List of IDs but why reordering if you already got the order?
Or you could reorder the result in your application.
But there’s another solution to order it in SQL. Using the “CASE-WHEN-THEN” Statement. It may not be very efficient if you have many IDs but that’s the best I found. Read more…