HPL/SQL is included to Apache Hive since version 2.0
HPL/SQL is included to Apache Hive since version 2.0
DECODE function allows you to implement IF-THEN-ELSE logic.
Syntax:
DECODE(expr, when_exp1, then_expr1 [, ...n] [, else_expr])
Notes:
Examples:
DECLARE var1 INT DEFAULT 3; PRINT DECODE (var1, 1, 'A', 2, 'B', 3, 'C'); -- Result: C PRINT DECODE (var1, 1, 'A', 2, 'B', 'C'); -- Result: C SET var1 = NULL; PRINT DECODE (var1, 1, 'A', 2, 'B', NULL, 'C'); -- Result: C
Compatibility: Oracle, IBM DB2 and Teradata
Version: PL/HQL 0.3.1
See also: