Trying to figure out how to do this in my CASE WHEN -- I am unsure of how to write this in my statement - what I am after, I need to take the Agent's [staffedtime] less their [idletime] then Subtract the sum of their total time on calls then divide / that it into the sum of their (Staffed minus their idletime) - this gives me a % of unproductive time If an agent's logged in time is [TotalStaffedTime] = 8.28 less their idle time of [IdleTime] = 1.52 (8.28-1.52) = 6.75 then, their total working time is [ContactTalkTime]+[PostCallProcessingTime]+[DNOutExtTalkTime]=3.43 =(6.75-3.43)/6.75 = 49.20%Hoping I can get some help, I tried this and I am getting a divide by zero error... '=([TotalStaffedTime] - [IdleTime]) - ([ContactTalkTime]+[PostCallProcessingTime]+[DNOutExtTalkTime]) / [TotalStaffedTime] - [IdleTime] [code="sql"]USE LDW_AvayaGOWITH A AS ( SELECT [TimeStamp] ,[AgentLogin] ,SUM([DNOutExtCalls]) as [DNOutExtCalls] ,SUM([DNOutExtCallsTalkTime]) AS [DNOutExtCallsTalkTime] FROM [LDW_Avaya].[dbo].[dAgentPerformanceStat] GROUP by [AgentLogin],[TimeStamp] )SELECT distinct CONVERT (varchar,[dAgentBySkillsetStat].TimeStamp,1) AS 'DATE' ,CAST([dAgentBySkillsetStat].[AgentLogin] as Int) as EXT ,[Skillset] ,[dAgentBySkillsetStat].[AgentSurname] + ' ' + [dAgentBySkillsetStat].[AgentGivenName] + ' - ' + [dAgentBySkillsetStat].[AgentLogin] as '[Name & ext]' ,ISNULL(SUM([CallsOffered]),0) AS 'CallOffered' ,ISNULL(SUM([CallsAnswered]),0) as 'CallsAnswered' ,ISNULL(SUM([PostCallProcessingTime]),0) as 'ACW' ,ISNULL(SUM([ContactTalkTime]),0) as 'ContactTime' ,a.[DNOutExtCalls] ,a.[DNOutExtCallsTalkTime] ,[NotReadyTime] ,[TotalStaffedTime] ,[IdleTime] ,CASE WHEN [TotalStaffedTime] = 0 THEN 0 ELSE [TotalStaffedTime]-[IdleTime] end as [Staffed Less Idle] ,CASE WHEN SUM([CallsAnswered]) = 0 THEN 0 ELSE SUM([ContactTalkTime]+[PostCallProcessingTime])/SUM([CallsAnswered]) END AS [AVG HANDLETIME] ,CASE WHEN SUM([TotalStaffedTime]) = 0 THEN 0 ELSE SUM([ContactTalkTime]+[PostCallProcessingTime]+[DNOutExtTalkTime]) END AS [TOTAL TIME ON PHONES] ,CASE WHEN [TotalStaffedTime] = 0 THEN 0 ELSE [IdleTime] / cast([TotalStaffedTime] as money) end as [(%) Of time in Idle] FROM [LDW_Avaya].[dbo].[dAgentBySkillsetStat] LEFT JOIN A ON [dAgentBySkillsetStat].[AgentLogin] = A.[AgentLogin] AND [dAgentBySkillsetStat].[TIMESTAMP] = A.[TIMESTAMP] WHERE [AgentGivenName] is not null GROUP BY [dAgentBySkillsetStat].[TimeStamp] ,[AgentSurname] ,[AgentGivenName] ,[dAgentBySkillsetStat].[AgentLogin] ,[IdleTime] ,[TotalStaffedTime] ,[NotReadyTime] ,a.[DNOutExtCalls] ,a.[DNOutExtCallsTalkTime] ,[Skillset] ORDER BY date[/code]
↧