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
 Transact-SQL (2000)
 division by 0

Author  Topic 

baska123
Yak Posting Veteran

64 Posts

Posted - 2006-08-16 : 11:53:54
I have this statement:
select (AssignmentTimeActualCost /((AssignmentTimeActualWork/1000)/60)) as Rate from msp_view_proj_assn_tp_by_day

How do you check for division by 0

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-16 : 12:03:01
add where condition

WHERE AssignmentTimeActualWork <> 0



KH

Go to Top of Page

baska123
Yak Posting Veteran

64 Posts

Posted - 2006-08-16 : 12:53:27
I also want to add that when it is 0 then put 0 in the AWPCost column
Go to Top of Page

baska123
Yak Posting Veteran

64 Posts

Posted - 2006-08-16 : 12:55:07
Here is what I have so far:

select
AssignmentTimeActualWorkProtected * (AssignmentTimeActualCost /((AssignmentTimeActualWork/1000)/60)) as AWPCost
from
msp_view_proj_assn_tp_by_day

where ((AssignmentTimeActualWork/1000)/60) != 0
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-16 : 13:44:56
[code]select case when AssignmentTimeActualWork = 0 then 0 else AssignmentTimeActualCost / AssignmentTimeActualWork / 1000.0 / 60.0 end as Rate,
case when AssignmentTimeActualWork = 0 then 0 else AssignmentTimeActualWorkProtected * AssignmentTimeActualCost / AssignmentTimeActualWork / 1000.0 / 60.0 end as AWPCost
from msp_view_proj_assn_tp_by_day[/code]
Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -