Decode example

Use the decode function to create an if-then-else statement. In this example: if the color ID is 1000 the result is red; if the color ID is 1001 the result is blue; if the color ID is 1002 the result is yellow; otherwise the return value is none.
SELECT color_id,
DECODE (color_id, 1000, 'red', 1001, 'blue', 1002, 'yellow, 'none')
AS color_name
FROM colors;

Netezza Performance Server SQL implements the decode function as a variant of a simple case expression, and it is equivalent to the expression “case x when val1 then result 1 when val2 then result 2 else default end.” Except if both x and val1 contain NULL values, unlike a case expression, decode considers the NULL values to be equal.