Search notes:

Oracle SQL: DECODE

DECODE( expr
        val_1 , result_1 ,
        val_2 , result_2 ,
        val_3 , result_3 ,
)
Decode compares the value of expr with val_n and returns result_n for the first val_n that is equal to expr.

Default value

It's possible to add a default value which is returned if no values match:
DECODE( expr
        val_1 , result_1 ,
        …
        default_value
)

Special NULL treatment

decode compares null values differently than one is used to from Oracle in that decode considers null to be equal to null.
The following statement returns 42:
select
   decode( null ,
      null,  42,
     'xyz',  99,
             17)
from
   dual;

See also

The SQL Server equivalent for decode seems to be choose.

Index