请帮助提高效果,并使报告考虑时间间隔 我正在使用过滤器处理SSRS报告,但似乎我的时间间隔过滤器根本不起作用,报告性能非常疯狂(超过5分钟)。添加时间间隔过滤器变得更加疯狂。 为了得到24个可能的小时间隔,它提供了Interval菜单,我创建了这个存储过程,我从报告中调用Interval下拉过滤器菜单:
ALTER PROCEDURE [dbo].[SP_Calls_Time_Interval]
-- Add the parameters for the stored procedure here
@TZ INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT Distinct
--CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) AS Time,
Case
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '00:00:00.0000000' and '00:59:59.0000000' Then '00:00-01:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '01:00:00.0000000' and '01:59:59.0000000' Then '01:00-02:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '02:00:00.0000000' and '02:59:59.0000000' Then '02:00-03:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '03:00:00.0000000' and '03:59:59.0000000' Then '03:00-04:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '04:00:00.0000000' and '04:59:59.0000000' Then '04:00-05:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '05:00:00.0000000' and '05:59:59.0000000' Then '05:00-06:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '06:00:00.0000000' and '06:59:59.0000000' Then '06:00-07:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '07:00:00.0000000' and '07:59:59.0000000' Then '07:00-08:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '08:00:00.0000000' and '08:59:59.0000000' Then '08:00-09:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '09:00:00.0000000' and '09:59:59.0000000' Then '09:00-10:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '10:00:00.0000000' and '10:59:59.0000000' Then '10:00-11:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '11:00:00.0000000' and '11:59:59.0000000' Then '11:00-12:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '12:00:00.0000000' and '12:59:59.0000000' Then '12:00-13:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '13:00:00.0000000' and '13:59:59.0000000' Then '13:00-14:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '14:00:00.0000000' and '14:59:59.0000000' Then '14:00-15:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '15:00:00.0000000' and '15:59:59.0000000' Then '15:00-16:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '16:00:00.0000000' and '16:59:59.0000000' Then '16:00-17:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '17:00:00.0000000' and '17:59:59.0000000' Then '17:00-18:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '18:00:00.0000000' and '18:59:59.0000000' Then '18:00-19:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '19:00:00.0000000' and '19:59:59.0000000' Then '19:00-20:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '20:00:00.0000000' and '20:59:59.0000000' Then '20:00-21:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '21:00:00.0000000' and '21:59:59.0000000' Then '21:00-22:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '22:00:00.0000000' and '22:59:59.0000000' Then '22:00-23:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '23:00:00.0000000' and '23:59:59.0000000' Then '23:00-00:00'
Else 'To be Determined' End As Interval
FROM CA_Details_Sync
WHERE (disposition = 2 OR (disposition = 3 and callpriority <> 0)) AND ((dispskill = 702 AND dispvector = 1022)
OR(dispskill = 701 AND dispvector = 1021)
OR(dispskill = 924 AND dispvector = 1007) OR(dispskill = 923 AND dispvector = 1006) OR(dispskill = 611 AND dispvector = 1001) OR (dispskill = 613 AND dispvector = 1003)
OR (dispskill = 614 AND dispvector = 1004)
OR (dispskill IN (631) AND dispvector = 1009) OR (dispskill IN (616, 900) AND dispvector = 1006) OR (dispskill = 631 AND dispvector = 202)
OR (dispskill IN (617, 618, 901) AND dispvector = 1007)) AND (enddate < convert(date, getutcdate()))
GROUP BY CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime))
END
GO
主报告Dataset调用我创建的另一个存储过程:
USE [SPReports]
GO
/****** Object: StoredProcedure [dbo].[sp_GSC_Calls_Skills] Script Date: 9/29/2015 1:01:33 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_GSC_Calls_Skills]
-- Add the parameters for the stored procedure here
@YEAR NVARCHAR(255),
@MONTH NVARCHAR(255),
@SKILL NVARCHAR(255),
@TZ INT,
@Interval NVARCHAR(255)
AS
BEGIN
(SELECT YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) AS Year,
MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) AS Month,
COUNT(cads_id) AS Calls,
SUM(CASE [disposition] WHEN 2 THEN CAST(ringtime+queuetime AS float) / 86400 ELSE 0 END) AS answertimetf,
SUM(CASE [disposition] WHEN 2 THEN CAST(talktime AS float) / 86400 ELSE 0 END) AS durationtf,
CASE
WHEN dispskill IN ('611', '614') THEN 'GTK-English'
WHEN dispskill = '613' THEN 'GTK-Spanish'
WHEN dispskill IN ('616', '900', '631') THEN 'GTK-HSIA/GNOC'
WHEN dispskill IN ('617') THEN 'GTK-FTG'
WHEN dispskill IN ('618', '901') THEN 'GTK-VOD/ETVI'
WHEN dispskill IN ('923') THEN 'SNS-HSIA'
WHEN dispskill IN ('924') THEN 'SNS-VOC'
WHEN dispskill IN ('701') THEN 'T2-HSIA'
WHEN dispskill IN ('702') THEN 'T2-VOC'
ELSE cast(dispskill as nvarchar(3)) + '-' + dispskillname END AS SkillSet,
CASE
WHEN dispskill IN ('611', '614') THEN 3
WHEN dispskill = '613' THEN 4
WHEN dispskill IN ('616', '900', '631') THEN 5
WHEN dispskill IN ('617') THEN 6
WHEN dispskill IN ('618', '901') THEN 7
WHEN dispskill IN ('923') THEN 8
WHEN dispskill IN ('924') THEN 9
WHEN dispskill IN ('701') THEN 10
WHEN dispskill IN ('702') THEN 11
ELSE 0 END AS SkillSetPos,
DAY(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) AS Day,
SUM(CASE disposition WHEN 2 THEN 1 ELSE 0 END) AS Answered,
SUM(CASE disposition WHEN 3 THEN 1 ELSE 0 END) AS Abandoned, Case
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '00:00:00.0000000' and '00:59:59.0000000' Then '00:00-01:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '01:00:00.0000000' and '01:59:59.0000000' Then '01:00-02:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '02:00:00.0000000' and '02:59:59.0000000' Then '02:00-03:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '03:00:00.0000000' and '03:59:59.0000000' Then '03:00-04:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '04:00:00.0000000' and '04:59:59.0000000' Then '04:00-05:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '05:00:00.0000000' and '05:59:59.0000000' Then '05:00-06:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '06:00:00.0000000' and '06:59:59.0000000' Then '06:00-07:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '07:00:00.0000000' and '07:59:59.0000000' Then '07:00-08:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '08:00:00.0000000' and '08:59:59.0000000' Then '08:00-09:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '09:00:00.0000000' and '09:59:59.0000000' Then '09:00-10:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '10:00:00.0000000' and '10:59:59.0000000' Then '10:00-11:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '11:00:00.0000000' and '11:59:59.0000000' Then '11:00-12:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '12:00:00.0000000' and '12:59:59.0000000' Then '12:00-13:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '13:00:00.0000000' and '13:59:59.0000000' Then '13:00-14:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '14:00:00.0000000' and '14:59:59.0000000' Then '14:00-15:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '15:00:00.0000000' and '15:59:59.0000000' Then '15:00-16:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '16:00:00.0000000' and '16:59:59.0000000' Then '16:00-17:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '17:00:00.0000000' and '17:59:59.0000000' Then '17:00-18:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '18:00:00.0000000' and '18:59:59.0000000' Then '18:00-19:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '19:00:00.0000000' and '19:59:59.0000000' Then '19:00-20:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '20:00:00.0000000' and '20:59:59.0000000' Then '20:00-21:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '21:00:00.0000000' and '21:59:59.0000000' Then '21:00-22:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '22:00:00.0000000' and '22:59:59.0000000' Then '22:00-23:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '23:00:00.0000000' and '23:59:59.0000000' Then '23:00-00:00'
Else 'To be Determined' End As Interval
FROM CA_Details_Sync
WHERE (disposition = 2 OR (disposition = 3 and callpriority <> 0)) AND ((dispskill = 702 AND dispvector = 1022)
OR(dispskill = 701 AND dispvector = 1021)
OR(dispskill = 924 AND dispvector = 1007) OR(dispskill = 923 AND dispvector = 1006) OR(dispskill = 611 AND dispvector = 1001) OR (dispskill = 613 AND dispvector = 1003)
OR (dispskill = 614 AND dispvector = 1004)
OR (dispskill IN (631) AND dispvector = 1009) OR (dispskill IN (616, 900) AND dispvector = 1006) OR (dispskill = 631 AND dispvector = 202)
OR (dispskill IN (617, 618, 901) AND dispvector = 1007)) AND (enddate < convert(date, getutcdate()))
GROUP BY YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)),
MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)),
CASE
WHEN dispskill IN ('611', '614') THEN 'GTK-English'
WHEN dispskill = '613' THEN 'GTK-Spanish'
WHEN dispskill IN ('616', '900', '631') THEN 'GTK-HSIA/GNOC'
WHEN dispskill IN ('617') THEN 'GTK-FTG'
WHEN dispskill IN ('618', '901') THEN 'GTK-VOD/ETVI'
WHEN dispskill= '923' THEN 'SNS-HSIA'
WHEN dispskill='924' THEN 'SNS-VOC'
WHEN dispskill='701' THEN 'T2-HSIA'
WHEN dispskill IN ('702') THEN 'T2-VOC'
ELSE cast(dispskill as nvarchar(3)) + '-' + dispskillname END,
DAY(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)),
CASE
WHEN dispskill IN ('611', '614') THEN 3
WHEN dispskill = '613' THEN 4
WHEN dispskill IN ('616', '900', '631') THEN 5
WHEN dispskill IN ('617') THEN 6
WHEN dispskill IN ('618', '901') THEN 7
WHEN dispskill IN ('923') THEN 8
WHEN dispskill IN ('924') THEN 9
WHEN dispskill IN ('701') THEN 10
WHEN dispskill IN ('702') THEN 11
ELSE 0 END,
CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime))
HAVING (YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) IN
(SELECT Value
FROM dbo.FnSplit(@Year, ',') AS FnSplit_2)) AND
(MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) IN
(SELECT Value
FROM dbo.FnSplit(@Month, ',') AS FnSplit_1))
AND
(CASE WHEN dispskill IN ('611', '614') THEN 'GTK-English'
WHEN dispskill = '613' THEN 'GTK-Spanish'
WHEN dispskill IN ('616', '900', '631') THEN 'GTK-HSIA/GNOC'
WHEN dispskill IN ('617') THEN 'GTK-FTG'
WHEN dispskill IN ('618', '901') THEN 'GTK-VOD/ETVI'
WHEN dispskill= '923' THEN 'SNS-HSIA'
WHEN dispskill='924' THEN 'SNS-VOC'
WHEN dispskill='701' THEN 'T2-HSIA'
WHEN dispskill IN ('702') THEN 'T2-VOC'
ELSE cast(dispskill as nvarchar(3)) + '-' + dispskillname END IN
(SELECT Value
FROM dbo.FnSplit(@Skill, ',') AS FnSplit_3)))
UNION
(SELECT YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, CONVERT(date, [Enter Queue]))) + CONVERT(time, [Enter Queue])) AS Year,
MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, CONVERT(date, [Enter Queue]))) + CONVERT(time, [Enter Queue])) AS Month,
COUNT(id) AS Calls,
Sum(CASE WHEN Status IN ('COMPLETE', 'TRANSFER') THEN CAST(DATEPART(MINUTE, [Queue Wait])*60+DATEPART(SECOND, [Queue Wait]) AS float) / 86400 ELSE 0 END) AS ringtimetf,
Sum(CASE WHEN status IN ('COMPLETE', 'TRANSFER') THEN CAST(duration1 AS float) / 86400 ELSE 0 END) AS durationtf,
CASE WHEN [Application] IN ('GTK - English','GTK - English Extended Stay','GTK - English Four Seasons','GTK - English GPNS','GTK - English Hilton','GTK - English Marriot',
'GTK - English WCH', 'GTK - LaQuinta', 'gtkEN', 'gtkENfourSeasons', 'gtkENgpns', 'gtkENLaQuinta', 'gtkENMarriot') THEN 'Conectys English'
WHEN [Application] IN ('gtkFR', 'gtkFRgpns', 'gtkFRMarriot') THEN 'Conectys French' END AS SkillSet,
CASE WHEN [Application] IN ('GTK - English', 'GTK - English Extended Stay', 'GTK - English Four Seasons', 'GTK - English GPNS', 'GTK - English Hilton', 'GTK - English Marriot',
'GTK - English WCH', 'GTK - LaQuinta', 'gtkEN', 'gtkENfourSeasons', 'gtkENgpns', 'gtkENLaQuinta', 'gtkENMarriot') THEN 1
WHEN [Application] IN ('gtkFR', 'gtkFRgpns', 'gtkFRMarriot') THEN 2 END AS SkillSetPos,
DAY(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, CONVERT(date, [Enter Queue]))) + CONVERT(time, [Enter Queue])) AS Day,
SUM(CASE WHEN status IN ('COMPLETE', 'TRANSFER') THEN 1 ELSE 0 END) AS Answered,
SUM(CASE WHEN status IN ('LOST', 'TIME OUT') THEN 1 ELSE 0 END) AS Abandoned, Case
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '00:00:00.0000000' and '00:59:59.0000000' Then '00:00-01:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '01:00:00.0000000' and '01:59:59.0000000' Then '01:00-02:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '02:00:00.0000000' and '02:59:59.0000000' Then '02:00-03:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '03:00:00.0000000' and '03:59:59.0000000' Then '03:00-04:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '04:00:00.0000000' and '04:59:59.0000000' Then '04:00-05:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '05:00:00.0000000' and '05:59:59.0000000' Then '05:00-06:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '06:00:00.0000000' and '06:59:59.0000000' Then '06:00-07:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '07:00:00.0000000' and '07:59:59.0000000' Then '07:00-08:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '08:00:00.0000000' and '08:59:59.0000000' Then '08:00-09:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '09:00:00.0000000' and '09:59:59.0000000' Then '09:00-10:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '10:00:00.0000000' and '10:59:59.0000000' Then '10:00-11:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '11:00:00.0000000' and '11:59:59.0000000' Then '11:00-12:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '12:00:00.0000000' and '12:59:59.0000000' Then '12:00-13:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '13:00:00.0000000' and '13:59:59.0000000' Then '13:00-14:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '14:00:00.0000000' and '14:59:59.0000000' Then '14:00-15:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '15:00:00.0000000' and '15:59:59.0000000' Then '15:00-16:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '16:00:00.0000000' and '16:59:59.0000000' Then '16:00-17:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '17:00:00.0000000' and '17:59:59.0000000' Then '17:00-18:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '18:00:00.0000000' and '18:59:59.0000000' Then '18:00-19:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '19:00:00.0000000' and '19:59:59.0000000' Then '19:00-20:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '20:00:00.0000000' and '20:59:59.0000000' Then '20:00-21:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '21:00:00.0000000' and '21:59:59.0000000' Then '21:00-22:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '22:00:00.0000000' and '22:59:59.0000000' Then '22:00-23:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) between '23:00:00.0000000' and '23:59:59.0000000' Then '23:00-00:00'
Else 'To be Determined' End As Interval
FROM Connectys_Calls
WHERE (CONVERT(date, [Enter Queue]) < CONVERT(DATE, GETUTCDATE())) AND Status <> 'CUSTOMER EXIT' AND [Application] LIKE 'G%'
AND
(YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, CONVERT(date, [Enter Queue]))) + CONVERT(time, [Enter Queue])) IN
(SELECT Value
FROM dbo.FnSplit(@Year, ',') AS FnSplit_2)) AND
(MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, CONVERT(date, [Enter Queue]))) + CONVERT(time, [Enter Queue])) IN
(SELECT Value
FROM dbo.FnSplit(@Month, ',') AS FnSplit_1))
GROUP BY YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, CONVERT(date, [Enter Queue]))) + CONVERT(time, [Enter Queue])),
MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, CONVERT(date, [Enter Queue]))) + CONVERT(time, [Enter Queue])),
DAY(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, CONVERT(date, [Enter Queue]))) + CONVERT(time, [Enter Queue])),
CASE WHEN [Application] IN ('GTK - English', 'GTK - English Extended Stay', 'GTK - English Four Seasons', 'GTK - English GPNS', 'GTK - English Hilton', 'GTK - English Marriot',
'GTK - English WCH', 'GTK - LaQuinta', 'gtkEN', 'gtkENfourSeasons', 'gtkENgpns', 'gtkENLaQuinta', 'gtkENMarriot') THEN 'Conectys English' WHEN [Application] IN ('gtkFR',
'gtkFRgpns', 'gtkFRMarriot') THEN 'Conectys French' END,
CASE WHEN [Application] IN ('GTK - English', 'GTK - English Extended Stay','GTK - English Four Seasons','GTK - English GPNS','GTK - English Hilton','GTK - English Marriot',
'GTK - English WCH','GTK - LaQuinta','gtkEN','gtkENfourSeasons','gtkENgpns','gtkENLaQuinta','gtkENMarriot') THEN 1
WHEN [Application] IN ('gtkFR','gtkFRgpns',
'gtkFRMarriot') THEN 2 END ,CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue])))
HAVING
(CASE WHEN [Application] IN ('GTK - English', 'GTK - English Extended Stay','GTK - English Four Seasons','GTK - English GPNS','GTK - English Hilton','GTK - English Marriot',
'GTK - English WCH','GTK - LaQuinta','gtkEN','gtkENfourSeasons', 'gtkENgpns','gtkENLaQuinta','gtkENMarriot') THEN 'Conectys English'
WHEN [Application] IN ('gtkFR','gtkFRgpns','gtkFRMarriot') THEN 'Conectys French' END IN
(SELECT Value
FROM dbo.FnSplit(@Skill, ',') AS FnSplit_3)))
END
GO
答案 0 :(得分:0)
在您的查询中,您反复进行大量计算 - 尤其是您的时间间隔。
我会创建一个子查询,添加一个时间间隔计算的列:
....
SUM(CASE WHEN status IN ('COMPLETE', 'TRANSFER') THEN 1 ELSE 0 END) AS Answered,
SUM(CASE WHEN status IN ('LOST', 'TIME OUT') THEN 1 ELSE 0 END) AS Abandoned,
RIGHT('00' + CAST(Hour_Interval AS VARCHAR(10)), 2) + ':00-' + RIGHT('00' + CAST(@HOURS + 1 AS VARCHAR(10)), 2) + ':00' AS INTERVAL
Else 'To be Determined' End As Interval
FROM ( SELECT * , DATEPART(HOUR, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, [Enter Queue]))) End As Hour_Interval
FROM Connectys_Calls ) AS CC
....
对于时间间隔过滤器下拉列表,是否真的需要调用实际数据集?如果您在大多数时间内拥有所有值,只需提供所有小时范围:
DECLARE @HOURS AS INTEGER = 0
SELECT @HOURS AS HOURS, RIGHT('00' + CAST(@HOURS AS VARCHAR(10)), 2) + ':00-' + RIGHT('00' + CAST(@HOURS + 1 AS VARCHAR(10)), 2) + ':00' AS RANGES
INTO #TEMP_HOURS
SET @HOURS = @HOURS + 1
WHILE @HOURS <24
BEGIN
INSERT INTO #TEMP_HOURS
SELECT @HOURS AS HOURS, RIGHT('00' + CAST(@HOURS AS VARCHAR(10)), 2) + ':00-' + RIGHT('00' + CAST(@HOURS + 1 AS VARCHAR(10)), 2) + ':00' AS RANGES
SET @HOURS = @HOURS + 1
END
SELECT * FROM #TEMP_HOURS
答案 1 :(得分:0)
运行它需要不到5分钟的时间:
Declare @YEAR NVARCHAR(255)
Set @Year='2015'
Declare @MONTH NVARCHAR(255)
Set @Month='9'
Declare @SKILL NVARCHAR(255)
Set @Skill= 'GTK-English,Conectys English,Conectys French'
--@SOURCE NVARCHAR(255),
Declare @TZ INT
Set @TZ=0
Declare @Interval NVARCHAR(255)
Set @Interval='06:00-07:00,07:00-08:00'
(SELECT YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) AS Year,
MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) AS Month,
COUNT(cads_id) AS Calls,
SUM(CASE [disposition] WHEN 2 THEN CAST(ringtime+queuetime AS float) / 86400 ELSE 0 END) AS answertimetf,
SUM(CASE [disposition] WHEN 2 THEN CAST(talktime AS float) / 86400 ELSE 0 END) AS durationtf,
CASE
WHEN dispskill IN ('611', '614') THEN 'GTK-English'
WHEN dispskill = '613' THEN 'GTK-Spanish'
WHEN dispskill IN ('616', '900', '631') THEN 'GTK-HSIA/GNOC'
WHEN dispskill IN ('617') THEN 'GTK-FTG'
WHEN dispskill IN ('618', '901') THEN 'GTK-VOD/ETVI'
WHEN dispskill IN ('923') THEN 'SNS-HSIA'
WHEN dispskill IN ('924') THEN 'SNS-VOC'
WHEN dispskill IN ('701') THEN 'T2-HSIA'
WHEN dispskill IN ('702') THEN 'T2-VOC'
ELSE cast(dispskill as nvarchar(3)) + '-' + dispskillname END AS SkillSet,
CASE
WHEN dispskill IN ('611', '614') THEN 3
WHEN dispskill = '613' THEN 4
WHEN dispskill IN ('616', '900', '631') THEN 5
WHEN dispskill IN ('617') THEN 6
WHEN dispskill IN ('618', '901') THEN 7
WHEN dispskill IN ('923') THEN 8
WHEN dispskill IN ('924') THEN 9
WHEN dispskill IN ('701') THEN 10
WHEN dispskill IN ('702') THEN 11
ELSE 0 END AS SkillSetPos,
DAY(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) AS Day,
SUM(CASE disposition WHEN 2 THEN 1 ELSE 0 END) AS Answered,
SUM(CASE disposition WHEN 3 THEN 1 ELSE 0 END) AS Abandoned, Case
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '00:00:00.0000000' and '00:59:59.0000000' Then '00:00-01:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '01:00:00.0000000' and '01:59:59.0000000' Then '01:00-02:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '02:00:00.0000000' and '02:59:59.0000000' Then '02:00-03:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '03:00:00.0000000' and '03:59:59.0000000' Then '03:00-04:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '04:00:00.0000000' and '04:59:59.0000000' Then '04:00-05:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '05:00:00.0000000' and '05:59:59.0000000' Then '05:00-06:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '06:00:00.0000000' and '06:59:59.0000000' Then '06:00-07:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '07:00:00.0000000' and '07:59:59.0000000' Then '07:00-08:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '08:00:00.0000000' and '08:59:59.0000000' Then '08:00-09:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '09:00:00.0000000' and '09:59:59.0000000' Then '09:00-10:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '10:00:00.0000000' and '10:59:59.0000000' Then '10:00-11:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '11:00:00.0000000' and '11:59:59.0000000' Then '11:00-12:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '12:00:00.0000000' and '12:59:59.0000000' Then '12:00-13:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '13:00:00.0000000' and '13:59:59.0000000' Then '13:00-14:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '14:00:00.0000000' and '14:59:59.0000000' Then '14:00-15:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '15:00:00.0000000' and '15:59:59.0000000' Then '15:00-16:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '16:00:00.0000000' and '16:59:59.0000000' Then '16:00-17:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '17:00:00.0000000' and '17:59:59.0000000' Then '17:00-18:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '18:00:00.0000000' and '18:59:59.0000000' Then '18:00-19:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '19:00:00.0000000' and '19:59:59.0000000' Then '19:00-20:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '20:00:00.0000000' and '20:59:59.0000000' Then '20:00-21:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '21:00:00.0000000' and '21:59:59.0000000' Then '21:00-22:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '22:00:00.0000000' and '22:59:59.0000000' Then '22:00-23:00'
When CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) between '23:00:00.0000000' and '23:59:59.0000000' Then '23:00-00:00'
Else 'To be Determined' End As Interval
FROM CA_Details_Sync
WHERE (disposition = 2 OR (disposition = 3 and callpriority <> 0)) AND ((dispskill = 702 AND dispvector = 1022)
OR(dispskill = 701 AND dispvector = 1021)
OR(dispskill = 924 AND dispvector = 1007) OR(dispskill = 923 AND dispvector = 1006) OR(dispskill = 611 AND dispvector = 1001) OR (dispskill = 613 AND dispvector = 1003)
OR (dispskill = 614 AND dispvector = 1004)
OR (dispskill IN (631) AND dispvector = 1009) OR (dispskill IN (616, 900) AND dispvector = 1006) OR (dispskill = 631 AND dispvector = 202)
OR (dispskill IN (617, 618, 901) AND dispvector = 1007)) AND (enddate < convert(date, getutcdate()))
GROUP BY YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)),
MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)),
CASE
WHEN dispskill IN ('611', '614') THEN 'GTK-English'
WHEN dispskill = '613' THEN 'GTK-Spanish'
WHEN dispskill IN ('616', '900', '631') THEN 'GTK-HSIA/GNOC'
WHEN dispskill IN ('617') THEN 'GTK-FTG'
WHEN dispskill IN ('618', '901') THEN 'GTK-VOD/ETVI'
WHEN dispskill= '923' THEN 'SNS-HSIA'
WHEN dispskill='924' THEN 'SNS-VOC'
WHEN dispskill='701' THEN 'T2-HSIA'
WHEN dispskill IN ('702') THEN 'T2-VOC'
ELSE cast(dispskill as nvarchar(3)) + '-' + dispskillname END,
DAY(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)),
CASE
WHEN dispskill IN ('611', '614') THEN 3
WHEN dispskill = '613' THEN 4
WHEN dispskill IN ('616', '900', '631') THEN 5
WHEN dispskill IN ('617') THEN 6
WHEN dispskill IN ('618', '901') THEN 7
WHEN dispskill IN ('923') THEN 8
WHEN dispskill IN ('924') THEN 9
WHEN dispskill IN ('701') THEN 10
WHEN dispskill IN ('702') THEN 11
ELSE 0 END,
CONVERT(TIME, DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime))
HAVING (YEAR(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) IN
(SELECT Value
FROM dbo.FnSplit(@Year, ',') AS FnSplit_2)) AND
(MONTH(DATEADD(HH, - (1 * DATEPART(HH, getutcdate() - GETDATE()) * @TZ), CONVERT(datetime, enddate)) + CONVERT(time, endtime)) IN
(SELECT Value
FROM dbo.FnSplit(@Month, ',') AS FnSplit_1))
AND
(CASE WHEN dispskill IN ('611', '614') THEN 'GTK-English'
WHEN dispskill = '613' THEN 'GTK-Spanish'
WHEN dispskill IN ('616', '900', '631') THEN 'GTK-HSIA/GNOC'
WHEN dispskill IN ('617') THEN 'GTK-FTG'
WHEN dispskill IN ('618', '901') THEN 'GTK-VOD/ETVI'
WHEN dispskill= '923' THEN 'SNS-HSIA'
WHEN dispskill='924' THEN 'SNS-VOC'
WHEN dispskill='701' THEN 'T2-HSIA'
WHEN dispskill IN ('702') THEN 'T2-VOC'
ELSE cast(dispskill as nvarchar(3)) + '-' + dispskillname END IN
(SELECT Value
FROM dbo.FnSplit(@Skill, ',') AS FnSplit_3)))