decode

The decode() function is equivalent to the IF:ELSE IF:ELSE or SWITCH statements. It is interpreted as IF:THEN:ELSEIF:THEN:ELSE. You can have multiple ELSEIF statements to achieve the needed evaluations.

Note: In decode and conditional expressions, null is treated differently. Theoretically the result from both the following expressions is expected to be the same, but null is treated differently in each expression.
  • Select decode(null, null, 1, 2) from dual. It returns 1 because decode assumes null = null.
  • Select case when null = null then 1 ELSE 2 end from dual. It returns 2 because this statement assumes null is not equal to null.
decode(test_expr, expr1, return1, expr2, ..., exprN, returnN,
returnX) 
Table 1. decode Function examples
Expression Result
DECODE( [Cell]![{Nok.Traffic.TCH_call_req}], nullInt(), 
[Cell]![{Neutral.TCH.call_seizure_attempts}] , 
[Cell]![{Nok.Traffic.TCH_call_req}])

Use of decode function to select an alternative metric where a vendor-specific metric is NULL.

If Nok.Traffic.TCH_call_req is NULL, then
return Neutral.TCH.call_seizure_attempts
Else return Nok.Traffic.TCH_call_req.