Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With Case Statement

Status
Not open for further replies.

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
 
Look here:

thread183-1530398


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top