Solved

divide by zero error

Posted on 2015-02-05
2
170 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
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 …

773 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