請性能方面提供幫助,也使報告花時間間隔考慮 我在SSRS報告與過濾器的工作,但似乎我的時間間隔過濾器在所有和不工作報告表現瘋狂(超過5分鐘)。它增加了時間間隔過濾器,令人瘋狂。 爲了獲得24個可能的時間間隔,其中飼料的間隔菜單,我創造了這個存儲過程,這是我從報告只是爲間隔調用下拉過濾器菜單:指定SSRS時間間隔
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
主要報表數據集通話我這樣創造了另一個存儲過程:
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
非常感謝您回答。您建議的時間間隔菜單運行時間不到一秒鐘。我很感激。但對於實際的報道,我似乎不明白從兩張桌子上獲得時間的方式。因此,它不起作用。你能否提供更多細節? – ML350