• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

Divide by zero error encountered

Working on an Access ADP with SQL backend.  I've got this one Function that keeps giving me this error. "Divide by zero error encountered".  This is the statement it gives me this error at:

CASE WHEN [todayconcpoured] > 0 THEN ((([todayconcpoured] / [todaytightconc]) - 1) * 100) ELSE 0 END

Both fields have 0's instead of nulls.  
I have been researching this on EE and I have tried with no success :

CASE WHEN [todayconcpoured] > 0 THEN ((([todayconcpoured] / CASE WHEN [todaytightconc] IS NULL THEN 0 ELSE [todaytightconc] END) - 1) * 100) ELSE 0 END

Can someone help me with this please?
Thanks
SCS1ST
0
SCS1ST
Asked:
SCS1ST
1 Solution
 
aprestoCommented:
CASE WHEN [todayconcpoured] > 0 AND [todayconcpoured] IS NOT NULL THEN

try that
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this should work better:
CASE
  WHEN [todayconcpoured] IS NULL OR [todaytightconc] IS NULL THEN 0
  WHEN [todaytightconc] > 0 THEN ((([todayconcpoured] / [todaytightconc]) - 1) * 100)
  ELSE 0 END
0
 
SCS1STAuthor Commented:
AngelIII,

Worked beautifully, thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now