1
我有一個查詢涉及到一個Extranet報告,我最近被要求調整以排除週末的SLA計算 - 我無能爲力 - 有人能請幫忙嗎?從SLA中排除週末日期
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
Modified Date: Modified By: Description:
19/03/2014 RC Created for extranet report 'IA Booking to IA timings'
29/04/2014 MC Adjusted SLAs
*/
ALTER PROCEDURE [dbo].[rex_IABookingToIA]
@Start_Date DATETIME,
@End_Date DATETIME
AS
set dateformat dmy
--declare @Start_Date DATETIME
--declare @End_Date DATETIME
--set @Start_Date = '10/03/2014'
--set @End_Date = '11/03/2014'
SELECT
AppointmentBookedBy
,count(CaseID) AS [Total IA Bookings]
,SUM(CASE WHEN datediff(dd,AppointmentBooked_DateTime,[Date]) BETWEEN 0 and 2
THEN 1 ELSE 0
END) AS [0 - 2 days]
,SUM(CASE WHEN datediff(dd,AppointmentBooked_DateTime,[Date]) BETWEEN 3 and 5
THEN 1 ELSE 0
END) AS [3 - 5 days]
,SUM(CASE WHEN datediff(dd,AppointmentBooked_DateTime,[Date]) BETWEEN 6 and 7
THEN 1 ELSE 0
END) AS [6 - 7 days]
,SUM(CASE WHEN datediff(dd,AppointmentBooked_DateTime,[Date]) > 7
THEN 1 ELSE 0
END) AS [8 days and over]
INTO #IABookings
FROM TICCSMI.dbo.array_PW_appointments[dbo]
WHERE AppointmentBooked_DateTime >= @Start_Date
and AppointmentBooked_DateTime < @End_Date
and [Type]='IA'
and [Department Booked By] = 'Physioworld Booking Team'
GROUP BY AppointmentBookedBy
ORDER BY AppointmentBookedBy
SELECT
AppointmentBookedBy AS [Agent]
,[Total IA Bookings]
,[0 - 4 days]
,CASE WHEN ([0 - 2 days] = 0 OR [Total IA Bookings] = 0) THEN CAST(0 AS DECIMAL (10,2))
ELSE CAST(100.00*[0 - 2 days]/[Total IA Bookings] AS DECIMAL (10,2))
END AS [%]
,[3 - 5 days]
,CASE WHEN ([3 - 5 days] = 0 OR [Total IA Bookings] = 0) THEN CAST(0 AS DECIMAL (10,2))
ELSE CAST(100.00*[3 - 5 days]/[Total IA Bookings] AS DECIMAL (10,2))
END AS [%]
,[6 - 7 days]
,CASE WHEN ([6 - 7 days] = 0 OR [Total IA Bookings] = 0) THEN CAST(0 AS DECIMAL (10,2))
ELSE CAST(100.00*[6 - 7 days]/[Total IA Bookings] AS DECIMAL (10,2))
END AS [%]
,[8 days and over]
,CASE WHEN ([8 days and over] = 0 OR [Total IA Bookings] = 0) THEN CAST(0 AS DECIMAL (10,2))
ELSE CAST(100.00*[8 days and over]/[Total IA Bookings] AS DECIMAL (10,2))
END AS [%]
FROM #IABookings
ORDER BY AppointmentBookedBy
所以 - 我需要ABL埃託奧拿起如果預訂是在週末提出,但被的SLA部分時間不包括週末。
在此先感謝