Solved

divide by zero error

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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