Built-in Functions → ifNull

ifNull() is a string function that returns one of two expressions depending on whether one of the expressions is NULL. If the first expression evaluates to NULL, ifNull() returns the second expression, otherwise, it returns the first expression.

Signature

ifNull(exp1, exp2)

The following table illustrates the ifNull() parameters:

ParameterDescription
exp1expression to check for a NULL value
exp2expression to return if exp1 is NULL

Both expressions can evaluate to a string, date or timestamp.

Returns

string, date or timestamp

Example

Evaluate the PROD_COST column values and return 0 if data is missing.

ifNull(Sales.Products.PROD_COST, 0)