Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Divide by zero error encountered

Posted on 2006-07-06
Medium Priority
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?
Question by:SCS1ST
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
LVL 23

Expert Comment

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

try that
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 2000 total points
ID: 17050851
this should work better:
  WHEN [todayconcpoured] IS NULL OR [todaytightconc] IS NULL THEN 0
  WHEN [todaytightconc] > 0 THEN ((([todayconcpoured] / [todaytightconc]) - 1) * 100)

Author Comment

ID: 17050973

Worked beautifully, thanks.

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

618 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