**Description**

IF THEN ELSE statements return one of two possible values, or perform one of two possible computations, depending on whether some condition is met.

The defined condition follows the keyword IF and can be constructed using any of the filtering keywords or relational operators (IN, NOT IN, BETWEEN, NOT BETWEEN, =, < , <=, >, >=, <>).

The first possible outcome follows the keyword THEN, and the second possible outcome follows the keyword ELSE. The outcomes that are returned can be numerical values or arithmetic operations. All IF THEN ELSE statements conclude with the END keyword.

If there more than two possible conditions to be defined, use the CASE statement.

**Syntax**

SELECT IF … THEN … ELSE … END

SELECT IF *condition* THEN *number* ELSE *number* END

SELECT IF *condition* THEN *arithmetic_operation* ELSE *arithmetic_operation* END

**Examples**

SELECT IF SUM(**Amount**)>= AVG(**Amount**) THEN 10 ELSE 0 END

SELECT IF SUM(**Duration**) - AVG(**Duration**) > 2000 THEN 0 ELSE 1 END

SELECT IF AVG(**Probability**) > 0.5 THEN SUM(**Amount**) * 10 ELSE SUM(**Amount**) / 10 END