Solved

How do I fix divide by zero error message?

Posted on 2008-06-17
3
297 Views
Last Modified: 2010-03-20
I'm using the following formula to create a new column and I'm getting an error message that says 'Divide by zero error encountered'.  How do i fix this?

cast((rate/quantity) as numeric (9,2)) PerRate

Thanks.
0
Comment
Question by:vsllc
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21807599
simple CASE syntax:
cast( CASE WHEN quantity = 0 THEN 0 ELSE rate/quantity END as numeric (9,2)) PerRate

Open in new window

0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 21807604
Hello vsllc,


case when quantity >o then cast((rate/quantity) as numeric (9,2))    else 0  end PerRate


GOD BLESS,

Aneesh R.
0
 

Author Comment

by:vsllc
ID: 21807715
Thanks.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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