When I run a SQL query it successfully executes but when I try to “create table as” or export the results, I get the error message “SQL Error [1476] [22012]: ORA-01476: divisor is equal to zero”.
I have read many suggestions on google saying use NULLIF, however, this doesn’t seem to be working for me when I place it into the equations that my SQL query is running. I’ve tried to place it on the outside of the full equations, just in the denominator of the equation or just the part of the equation that contains the calculation with the denominator. Examples of what I have tried are listed below. After I run my query with the update including the NULLIF, I get the error message “SQL Error [909] [42000]: ORA-00909: invalid number of arguments”, what am I doing wrong?
Without NULLIF:
EMS * “InhalationChronicREL” * (1 / 8760) * (1 / “InhalationChronicREL”) * 150 AS CHRONIC_TWE
With NULLIF on outside of EQN:
NULLIF(EMS * “InhalationChronicREL” * (1 / 8760) * (1 / “InhalationChronicREL”) * 150) AS CHRONIC_TWE
*With NULLIF on part of EQN that includes denominator where a zero is possible: *
EMS * “InhalationChronicREL” * (1 / 8760) * NULLIF(1 / “InhalationChronicREL”) * 150 AS CHRONIC_TWE
*With NULLIF in denominator where a zero is possible: *
EMS * “InhalationChronicREL” * (1 / 8760) * (1 / NULLIF(“InhalationChronicREL”)) * 150 AS CHRONIC_TWE
I’ve tried placing null if in areas that might help the divisor not be equal to zero. Once I do this I then get an error message saying “SQL Error [909] [42000]: ORA-00909: invalid number of arguments”. I was expecting the NULLIF function to allow me to export the data from my SQL query once I got rid of the divisor equal to zero issue.
Melissa Traverso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.