November 14, 2011 at 3:49 am
I have the following
SELECT #callhandling2.client
,#callhandling2.daycat+' '+#callhandling2.timecat as [Category]
,Sum(#callhandling2.calls) as [Total Calls]
,[Calls Per 30 Mins] = Case
When #callhandling2.daycat+' '+#callhandling2.timecat='Weekend 20:00-08:00' then if(iserror(Sum(#callhandling2.calls)/2208.0)),0,Sum(#callhandling2.calls)/2208.0
When #callhandling2.daycat+' '+#callhandling2.timecat='Weekend 08:00-20:00' then Sum(#callhandling2.calls)/2208.0
When #callhandling2.daycat+' '+#callhandling2.timecat='Weekday 20:00-08:00' then Sum(#callhandling2.calls)/5304.0
When #callhandling2.daycat+' '+#callhandling2.timecat='Weekday 08:00-20:00' then Sum(#callhandling2.calls)/5304.0
Else 'I dont know'
End
But have a problem with the if(iserror) bit of my case statement.
Basically I want to say if there is a division by 0 error then NA or something similar
November 14, 2011 at 3:57 am
carl.meads (11/14/2011)
I have the followingSELECT #callhandling2.client
,#callhandling2.daycat+' '+#callhandling2.timecat as [Category]
,Sum(#callhandling2.calls) as [Total Calls]
,[Calls Per 30 Mins] = Case
When #callhandling2.daycat+' '+#callhandling2.timecat='Weekend 20:00-08:00' then if(iserror(Sum(#callhandling2.calls)/2208.0)),0,Sum(#callhandling2.calls)/2208.0
When #callhandling2.daycat+' '+#callhandling2.timecat='Weekend 08:00-20:00' then Sum(#callhandling2.calls)/2208.0
When #callhandling2.daycat+' '+#callhandling2.timecat='Weekday 20:00-08:00' then Sum(#callhandling2.calls)/5304.0
When #callhandling2.daycat+' '+#callhandling2.timecat='Weekday 08:00-20:00' then Sum(#callhandling2.calls)/5304.0
Else 'I dont know'
End
But have a problem with the if(iserror) bit of my case statement.
Basically I want to say if there is a division by 0 error then NA or something similar
Wow, got a weird case of "deja-vu" here 😉
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply