Solved

divide by zero error

Posted on 2015-02-05
2
174 Views
Last Modified: 2015-02-05
this query is returning an error: Divide by zero error encounterd how do i fix it to make the result 0


SELECT     dbo.viewDocumentCount.[Project Name], dbo.viewDocumentCount.DocumentCount / CAST(dbo.viewTotalDays.TotalDays AS Float) AS DaysOpenAvg
FROM         dbo.viewDocumentCount INNER JOIN
                      dbo.viewTotalDays ON dbo.viewDocumentCount.ID = dbo.viewTotalDays.ID
0
Comment
Question by:vbnetcoder
[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
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40591294
SELECT     dbo.viewDocumentCount.[Project Name],
case CAST(dbo.viewTotalDays.TotalDays AS Float)
when 0 then 0
else
dbo.viewDocumentCount.DocumentCount / CAST(dbo.viewTotalDays.TotalDays AS Float)
end AS DaysOpenAvg
FROM         dbo.viewDocumentCount INNER JOIN
                      dbo.viewTotalDays ON dbo.viewDocumentCount.ID = dbo.viewTotalDays.ID
0
 

Author Closing Comment

by:vbnetcoder
ID: 40591350
ty
0

Featured Post

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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