if

Returns one of two values depending how a given boolean expression evaluates.

Example

Return “Great” if the country in COUNTRYNAME_ is “Spain” and “Other_Country” otherwise.

if(SALES.COUNTRIES.COUNTRY_NAME = "Spain", "Great", "Other_Country")

Syntax

if (bool expr, expr1, expr2)
  • expr : bool expression
  • expr1 : expression to evaluate if expr evaluates to true
  • expr2 : expression to evaluate if expr evaluates to false

    Returns

    <type> depending on what expr1 or expr2 evaluate to

Notes

Function if returns the expr1 if the boolean expression evaluates to true, otherwise it returns expr2. If the first and second expressions are numbers, the result will be of type double.