NVL2 (Lakehouse v1)
Returns <expr2> if <expr1> is not NULL; otherwise, it returns <expr3>.
Analyze Syntax
Section titled “Analyze Syntax”func.nvl2(<expr1> , <expr2> , <expr3>)Analyze Examples
Section titled “Analyze Examples”func.nvl2('a', 'b', 'c'), func.nvl2(null, 'b', 'c')
┌──────────────────────────────────────────────────────┐│ func.nvl2('a', 'b', 'c') │ func.nvl2(null, 'b', 'c') │├──────────────────────────┼───────────────────────────┤│ b │ c │└──────────────────────────────────────────────────────┘
func.nvl2(1, 2, 3), func.nvl2(null, 2, 3)
┌────────────────────────────────────────────┐│ func.nvl2(1, 2, 3) │ func.nvl2(null, 2, 3) │├────────────────────┼───────────────────────┤│ 2 │ 3 │└────────────────────────────────────────────┘SQL Syntax
Section titled “SQL Syntax”NVL2(<expr1> , <expr2> , <expr3>)SQL Examples
Section titled “SQL Examples”SELECT NVL2('a', 'b', 'c'), NVL2(NULL, 'b', 'c');
┌────────────────────────────────────────────┐│ nvl2('a', 'b', 'c') │ nvl2(null, 'b', 'c') │├─────────────────────┼──────────────────────┤│ b │ c │└────────────────────────────────────────────┘
SELECT NVL2(1, 2, 3), NVL2(NULL, 2, 3);
┌──────────────────────────────────┐│ nvl2(1, 2, 3) │ nvl2(null, 2, 3) │├───────────────┼──────────────────┤│ 2 │ 3 │└──────────────────────────────────┘