Solved

Divide by zero error encountered

Posted on 2006-07-06
3
328 Views
Last Modified: 2011-10-03
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
Comment
Question by:SCS1ST
3 Comments
 
LVL 23

Expert Comment

by:apresto
Comment Utility
CASE WHEN [todayconcpoured] > 0 AND [todayconcpoured] IS NOT NULL THEN

try that
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
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
 

Author Comment

by:SCS1ST
Comment Utility
AngelIII,

Worked beautifully, thanks.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now