ORA-01476: divisor is equal to zero
An expression divided by zero. Protect the division with NULLIF so that a zero divisor gives NULL instead of an error.
What ORA-01476 means
Oracle raises ORA-01476 when the divisor of a NUMBER expression is zero, and the whole statement fails, even if one row out of millions caused it. That is why a report can work for months and fail the day the first zero appears in the data.
Common causes of ORA-01476
- A column used as a divisor contains zero.
- A calculated divisor such as
a - bbecomes zero. - A percentage or average over an empty group.
- A
MOD-style calculation written by hand.
How to fix ORA-01476
- Use
NULLIF(divisor, 0): dividing by NULL gives NULL. - If you need a fixed result instead, wrap it:
NVL(a / NULLIF(b, 0), 0). - Use
CASE WHEN b <> 0 THEN a / b ENDif you prefer it spelled out. - Find the rows with
WHERE b = 0, and check whether zero is a valid value at all.
ORA-01476 example
NULLIF turns the zero into NULL:
-- ORA-01476: divisor is equal to zero
SELECT total / quantity FROM order_lines;
-- Works
SELECT total / NULLIF(quantity, 0) FROM order_lines;
In SQLlightspeed
When a statement fails, SQLlightspeed’s error panel shows the error code with a plain-language explanation and a suggestion for what to do next, together with Oracle’s own message and a link to Oracle’s documentation — for this error and dozens of other common ones.
Related errors
ORA-01722ORA-06502ORA-01438 All Oracle errors →
Oracle documentation for ORA-01476. Oracle is a registered trademark of Oracle Corporation. SQLlightspeed is not affiliated with Oracle.