Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL-HELP
The closest thing is the DECODE statement. Abbrev. syntax:
DECODE(Column, test_value1, return_value1, default_value)
You can add many more (test, return) pairs before the default value. And the default value is optional.
A real example can be like this:
SELECT col2,
col3, DECODE(col3, 'YES', 1, 'NO', 0, -1) True_false, col4
In this example if col3 it the string 'YES', the return value for the expression is the number 1; if it is the string 'NO', the return value is zero, if it is anything else, the return value is -1.
If you don't specify a default value, the return value is NULL.
This is just a simple contrived case. You can do much more with DECODE.
--
Ken Madsen
Received on Mon Aug 17 1998 - 12:49:42 CDT
![]() |
![]() |