0

Suppose I have a table where I have a field which can have to values: "enabled" and "disabled". Suppose want my query to output "unblocked" instead of "enabled" and "blocked" instead of "disabled". How to do that in Oracle?

1
  • Use CASE WHEN ... Commented Jul 14, 2014 at 12:57

1 Answer 1

0

Either use the SQL standard way of CASE WHEN ... as ypercybe suggested in the comments or for more neat result, DECODE function:

DECODE(fieldref, 'enabled', 'unblocked', 'disabled', 'blocked')
1
  • 1
    I think DECODE is less readable. So I decided to use CASE - it seams more understandable for the person who will join the team to maintain this code. But anyway, thanks, it is very interesting to know about this possibility. Commented Jul 14, 2014 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.