|Oracle® OLAP DML Reference
10g Release 1 (10.1)
Part Number B10339-02
The DECODE function compares one expression to one or more other expressions and, when the base expression is equal to a search expression, returns the corresponding result expression; or, when no match is found, returns the default expression when it is specified, or
NA when it is not.
The data type of the first search argument.
DECODE (expr , search, result [, search , result]... [, default])
The expression to be searched.
An expression to search for.
The expression to return when expression is equal to search.
An expression to return when expression is not equal to search.
The search, result, and default values can be derived from expressions. The function evaluates each search value only before comparing it to expr, rather than evaluating all search values before comparing any of them with expr. Consequently, the function never evaluates a search when a previous search is equal to expr.
The function automatically converts expr and each search value to the data type of the first search value before comparing. The function automatically converts the return value to the same data type as the first result.
The DECODE function considers two
NAs to be equivalent. When expr is
NA, then the function returns the result of the first search that is also