NullIfZero in Snowflake

Viewed 2564

I have to migrate Teradata Queries to Snowflake.

I'm dividing by a value that I need to cast as Null if the value is zero to avoid Divide by Zero errors, is there a function/syntax for this?

Balance/NULLIFZERO(Limit) AS UTILIZATION,
2 Answers
Balance/NULLIF(Limit, 0)

Btw, nullifzero is very old legacy syntax, Standard SQL's nullif should be used in Teradata, too.

Starting from 14.07.2020 Snowflake natively supports NULLIFZERO

Returns NULL if the argument evaluates to 0; otherwise, returns the argument.

NULLIFZERO( <expr> )
Related