// Oracle error reference
ORA-01476: divisor is equal to zero
An expression divided a number by zero. Guard the divisor with NULLIF or CASE so a zero gives NULL or a default instead.
- Error code
ORA-01476- Category
- Data values and conversion
What it means
ORA-01476 is raised when a numeric expression divides by zero. Note that a query can fail on rows you didn't expect, since Oracle may evaluate the expression for rows before applying every filter.
Common causes
- Ratios or percentages over rows where the total is zero.
- A divisor column that allows zero or a default of 0.
How to fix it
-
Turn a zero divisor into NULL.
SELECT clicks / NULLIF(impressions, 0) AS ctr FROM ad_stats;
-
Or return a default with
CASE.SELECT CASE WHEN impressions = 0 THEN 0 ELSE clicks / impressions END AS ctr FROM ad_stats;
Related errors
8134SQL Server: Divide by zero error encountered22012PostgreSQL: division by zeroORA-01722invalid number
More data values and conversion errors
ORA-12899value too large for columnORA-01401inserted value too large for columnORA-01438value larger than specified precisionORA-00932inconsistent datatypesORA-01843not a valid monthORA-01861literal does not match format stringORA-01830date format picture ends before end of input
The code and message text are from the Oracle Database Error Help. Browse the full Oracle error list or search every database error.
// fewer errors, faster fixes
Work on Oracle in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Oracle and the other databases you use.