Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Division by zero? 1

Status
Not open for further replies.

Haunter

Programmer
Jan 2, 2001
379
US
I am getting a division by Zero error. Obviously I have a field with contains 0 and I am selecting using this field.

Situation:

Select * where `field1`/`field2` > 10

if I set field2 to NULL with this problem go away?

The field is only 0 upon initialization of a new row. If I initialize the row to default fields to NULL with my statement succeed or will I still get errors?
 
It should be okay.

You can code a check so you always are on the safe side

Select * from t
where case when field2 = 0 or field2 is null then 0
else field1/field2 end > 10
 
Star for you. You have solved a headache for me. Tx

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top