Top
Symfoware Server V12.1.0 Application Development Guide
FUJITSU Software

9.4.1 DECODE

Features

Compares values and converts to other values.

Specification format

General rules

Example

In the following example, the value of col3 in table t1 is compared and converted to a different value. If the col3 value matches search value 1, the result value returned is "one". If the col3 value doe not match any of search values 1, 2, or 3, the default value "other number" is returned.

SELECT col1,
       DECODE(col3, 1, 'one',
                    2, 'two',
                    3, 'three',
                    'other number') "num-word"
       FROM t1;
col1  | num-word
------+----------
 1001 | one
 1002 | two
 1003 | three
(3 rows)