Skip Headers
Oracle® OLAP Expression Syntax Reference
Release 11.2

Part Number E23381-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

DECODE

DECODE compares an expression to one or more search strings one by one.

If expr is search, then DECODE returns the corresponding result. If there is no match, then DECODE returns default. If you omit default, then DECODE returns null.

Return Value

Data type of the first result argument

Syntax

DECODE(expr, search, result
          [, search, result ]...
          [, default ]
      )

Arguments

expr is an expression that is compared to one or more search strings.

search is a string that is searched for a match to expr.

result is the return value when expr matches the corresponding search string.

default is the return value when expr does not match any of the search strings. If default is omitted, then DECODE returns null.

The arguments can be any numeric or character type. Two nulls are equivalent. If expr is null, then DECODE returns the result of the first search that is also null.

The maximum number of components, including expr, searches, results, and default, is 255.

Example

DECODE(sysdate, '21-JUN-06', 'Summer Solstice', '21-DEC-06', 'Winter Solstice', 'Have a nice day!')

returns these values:

Summer Solstice on June 21, 2006

Winter Solstice on December 21, 2006

Have a nice day! on all other days