?
Solved

Divide by zero error encountered

Posted on 2006-07-06
3
Medium Priority
?
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

Expert Comment

by:apresto
ID: 17050845
CASE WHEN [todayconcpoured] > 0 AND [todayconcpoured] IS NOT NULL THEN

try that
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 17050851
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
ID: 17050973
AngelIII,

Worked beautifully, thanks.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

800 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