IF

If <cond1> is TRUE, it returns <expr1>. Otherwise if <cond2> is TRUE, it returns <expr2>, and so on.

Analyze Syntax

func.if(<cond1>, <expr1>, [<cond2>, <expr2> ...], <expr_else>)

Analyze Examples

func.if((1 > 2), 3, (4 < 5), 6, 7)

┌────────────────────────────────────┐
 func.if((1 > 2), 3, (4 < 5), 6, 7) 
├────────────────────────────────────┤
                                  6 
└────────────────────────────────────┘

SQL Syntax

IF(<cond1>, <expr1>, [<cond2>, <expr2> ...], <expr_else>)

SQL Examples

SELECT IF(1 > 2, 3, 4 < 5, 6, 7);

┌───────────────────────────────┐
 if((1 > 2), 3, (4 < 5), 6, 7) 
├───────────────────────────────┤
                             6 
└───────────────────────────────┘
Last modified April 25, 2024 at 8:41 PM EST: updating conditional functions (c113c0b)