Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 divide by zero issue

Author  Topic 

etietje
Starting Member

24 Posts

Posted - 2003-02-14 : 15:39:58
I need to do some quick math on a couple of fields, but one of them could be zero. I would like a way to easily set the field to 1 if it is a zero. How would I go about doing that??

example the way I have it now. sometimes valueB is a zero.

select * from TABLE
where .10 < (valueA / ValueB)

etietje
Starting Member

24 Posts

Posted - 2003-02-14 : 15:58:53
I knew I was having a brain freeze. Thanks.

EDIT: There was a message here about using CASE before...???

Edited by - etietje on 02/14/2003 16:00:50
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-02-14 : 16:06:11
Sorry, that was me. I deleted it because I was going to add more information to the post, but I didn't get around to doing it.

Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-02-14 : 19:42:50
SELECT *
FROM TABLE
WHERE
VALUEA / (CASE ValueB WHEN 0 THEN 1) > .10

The case statement would prevent the error however
is this logically correct??? Probably not.

Go to Top of Page
   

- Advertisement -