Decode
Encyclopedia : D : DE : DEC : Decode
DECODE is a single-row function in Oracle which applies conditional logic to SQL queries. This function works very much like an IF-THEN-ELSE statement.
Syntax:
DECODE (expression1, value1, return_value1, value2, return_value2, ... valueN, return_valueN, [default_return_value])
How it works
If expression1 equals value1 then return_value1 is returned by DECODE function, and if expression1 equals value2 then return_value2 is returned and so on…..
The optional default_return_value is returned if expression1 does not match with any of value1,value2,…..valueN values.
In short
IF expression1 = valueN THEN return_valueN ELSE default_return_value
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
