I'm trying to perform a SELECT
with an IN
clause and I would like to be able to have the results returned in the same order as the elements in my list for the IN
. For example:
SELECT * FROM orders WHERE order_no IN ('B123', 'B483', 'B100', 'B932', ...);
and I would want them to come back in that same order. Ideally, it'd be great if I could have a statement like:
SELECT * FROM orders WHERE order_no IN ('B123', 'B483', 'B100', 'B932', ...)
ORDER BY ('B123', 'B483', 'B100', 'B932', ...);
I've seen examples of queries using the CASE
or DECODE
keywords to define some sort of custom ordering. But, in all those examples, their ordering was for a predetermined set of options. Whereas, my ordering is completely dependent on what my user enters for their search criteria, so there could be a list of 2 options or a list of 100 to order by...
Any ideas? Some Oracle feature I don't know of, or some way to use CASE
or DECODE
for a dynamic set?