Using the DECODE() Function : DECODE « Conversion Functions « Oracle PL/SQL Tutorial






DECODE(value, search_value, result, default_value) compares value with search_value. If the values are equal, DECODE() returns result, otherwise default_value is returned. DECODE() allows you to perform if-then-else logic in SQL without having to use PL/SQL.

SQL> SELECT DECODE(1, 1, 2, 3)
  2  FROM dual;

DECODE(1,1,2,3)
---------------
              2

SQL>








15.2.DECODE
15.2.1.Using the DECODE() Function
15.2.2.SELECT DECODE(1, 2, 1, 3)
15.2.3.Use Decode in table column
15.2.4.Pass multiple search and result parameters to DECODE()
15.2.5.The null may be made more explicit with a DECODE statement
15.2.6.Decode as If statement
15.2.7.Demo range comparison with DECODE
15.2.8.DECODE in the GROUP BY clause
15.2.9.Use decode create dynamic select statement
15.2.10.Use decode as if statement and output 'high' or 'low'
15.2.11.decode column data to output more meaningful information