dataengref migrate

Home / Teradata

Teradata ZEROIFNULL in Snowflake, Databricks and BigQuery

Snowflake keeps ZEROIFNULL. Databricks and BigQuery have no such function; use COALESCE(x, 0) or IFNULL(x, 0).

Teradata function: ZEROIFNULL(arg) · Teradata docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeSame nameZEROIFNULL(expr)Returns 0 if the argument is NULL, otherwise the argument.Snowflake docs
DatabricksRewritecoalesce(expr, 0)ifnull(expr, 0) and nvl(expr, 0) are equivalent.Databricks docs
BigQueryRewriteIFNULL(expr, 0)COALESCE(expr, 0) is equivalent.BigQuery docs

Behavior differences to check

Examples

Treat missing sales as zero

Teradata
SELECT store_id, ZEROIFNULL(sales) AS sales FROM daily_sales;
Snowflake
SELECT store_id, ZEROIFNULL(sales) AS sales FROM daily_sales;
Databricks
SELECT store_id, coalesce(sales, 0) AS sales FROM daily_sales;
BigQuery
SELECT store_id, IFNULL(sales, 0) AS sales FROM daily_sales;

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.