renee35
MIS
- Jan 30, 2007
- 199
Is this Case Statement written correctly:
'AvgPayRate' = Case when sum(isnull(o.pay,0)) = 0 then 0
when sum (isnull(o.totalhours,0)) = 0 then 0 else sum(isnull(o.pay,0))/sum (isnull(o.totalhours,0)) end,
'AvgBillRate' = Case when sum(isnull(o.billing,0)) = 0 then 0
when sum (isnull(o.totalhours,0)) = 0 then 0 else sum(isnull(o.billing,0))/sum (isnull(o.totalhours,0)) end,
Reason I ask is because when it is entered into the code it sets one row of data to '0'.
I am trying to avoid getting this error:
Divide by zero error encountered.
The statement has been terminated.
Thanks,
Thanks a bunch!!
-T
'AvgPayRate' = Case when sum(isnull(o.pay,0)) = 0 then 0
when sum (isnull(o.totalhours,0)) = 0 then 0 else sum(isnull(o.pay,0))/sum (isnull(o.totalhours,0)) end,
'AvgBillRate' = Case when sum(isnull(o.billing,0)) = 0 then 0
when sum (isnull(o.totalhours,0)) = 0 then 0 else sum(isnull(o.billing,0))/sum (isnull(o.totalhours,0)) end,
Reason I ask is because when it is entered into the code it sets one row of data to '0'.
I am trying to avoid getting this error:
Divide by zero error encountered.
The statement has been terminated.
Thanks,
Thanks a bunch!!
-T