ZEROIFNULL

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns zero when input is NULL; otherwise, returns input unchanged.

Syntax 

1zeroifnull(<value>)

Arguments 

Required 

  • <value>: Numeric value to check.

Returns 

Returns input when it isn’t NULL. For NULL input, returns zero using the input’s numeric type.

Considerations 

  • Requires exactly one numeric argument.
  • ZEROIFNULL(NULL) returns 0.

Examples 

Replace NULL with zero 

Return zero when the input is NULL.

1SELECT zeroifnull(NULL) AS result;

Returns 0.

Preserve a non-NULL value 

Return the input when it isn’t NULL.

1SELECT zeroifnull(42) AS result;

Returns 42.

Related Documentation