103. DECODE - llighter/database GitHub Wiki
DECODE Database SQL Reference
Syntax

Purpose
DECODEcomparesexprto eachsearchvalue one by one.- If
expr is equal to asearch, then Oracle Database returns the correspondingresult`. - If no match is found, then Oracle returns
default. Ifdefaultis omitted, then Oracle returnsnull.
- The arguments can be any of the numeric types (
NUMBER,BINARY_FLOAT, orBINARY_DOUBLE) or character types. - The
search,result, anddefaultvalues can be derived from expressions. - Oracle Database uses short-circuit evaluation. :
νλ μ°ΎμΌλ©΄ λ μ΄μ λΉκ΅νμ§ μλλ€.
- In a
DECODEfunction, Oracle considers two nulls to be equivalent. - The maximum number of components in the
DECODEfunction, includingexpr,searches,results, anddefault, is 255.
Examples
SELECT product_id,
DECODE (warehouse_id, 1, 'Southlake',
2, 'San Francisco',
3, 'New Jersey',
4, 'Seattle',
'Non domestic')
"Location of inventory" FROM inventories
WHERE product_id < 1775;