Solved

How do I fix divide by zero error message?

Posted on 2008-06-17
3
298 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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