NULLIFZERO function replaces 0 values with NULL, and can be used to avoid division by zero, or to suppress printing zeros in reports i.e.
Quick Example:
Avoid division by zero:
SELECT amount / NULLIFZERO(store_count) FROM sales;
Summary information:
Syntax | NULLIFZERO(expression) | |
Alternatives | NULLIF(expression, 0) | NULLIF and CASE are ANSI SQL compliant |
CASE expression WHEN 0 THEN NULL ELSE expression END |
Related Functions:
ZEROIFNULL | Replace NULL values with 0 |
Last Update: Teradata 13
Replacing 0 values with NULL in other databases:
Oracle:
NULLIF(expression, 0) | NULLIF and CASE are ANSI SQL compliant |
CASE expression WHEN 0 THEN NULL ELSE expression END | |
DECODE(expression, 0, NULL, expression) |