I've got an Oracle 11g table with a column indicating statuses for a number of items. Is there any way to do a select where three specific flags are ordered first, and then the rest in alphabetical order?
Something similar to
SELECT ITEM, STATUS FROM FOO ORDER BY STATUS ('I', 'U', 'P') ASC
which would then list all items with status I, then U, then P, and then the remaining items last.
This works for all DB engines
SELECT ITEM, STATUS
FROM FOO
ORDER BY case when STATUS = 'I' then 1
when STATUS = 'U' then 2
when STATUS = 'P' then 3
else 4
end,
status
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With