我有一个数据集,显示了工人使用四种测试类型以及他们的主管和主管上方的主管对各种技能的分数.为了节省空间,下面的数据集示例仅适用于一个工作者.这就是我的开始:
Director Supervisor Worker Test Skill Score
Doris Smith Jane Awe Lorina Marc Overall 1: Identifying Support 1
Doris Smith Jane Awe Lorina Marc Test A 1: Identifying Support 4
Doris Smith Jane Awe Lorina Marc Test B 1: Identifying Support 1
Doris Smith Jane Awe Lorina Marc Test C 1: Identifying Support 5
Doris Smith Jane Awe Lorina Marc Overall 2: Tracking the Sequence 3
Doris Smith Jane Awe Lorina Marc Test A 2: Tracking the Sequence 2
Doris …Run Code Online (Sandbox Code Playgroud) 下面是一个包含临时表的大查询.我一直试图找出将其转换为存储过程的语法 - 我似乎无法弄明白.我认为能够使用变量@Report_Start_DT和选择日期范围@Report_End_DT.
CREATE PROCEDURE [gw_ppp].[dbo].[Prv_Child_Not_Seen] (@Report_Start_DT, @Report_End_DT)
as
BEGIN
DECLARE @Report_Start_DT datetime
DECLARE @Report_End_DT datetime
CREATE TABLE #Temp_Contact (
Person_ID INT,
Contact_Date DATETIME,
Success INT)
INSERT INTO #Temp_Contact (Person_ID, Contact_Date, Success)
SELECT Person_ID, Contact_Date,
gw_ppp.dbo.fnWasContacted(Contact_Method, Contact_Result, Participant)
FROM gw_dw.dbo.DimContacts_Child
where Contact_Date between DATEADD(month, -5, @Report_Start_DT) and DATEADD(day, -1, @Report_Start_DT)
CREATE TABLE #Temp_Months (
Month VARCHAR(30),
Year int
)
INSERT INTO #Temp_Months VALUES
('January', 2010),
('January', 2011),
('January', 2012),
('January', 2013),
('January', 2014),
('January', 2015),
('January', …Run Code Online (Sandbox Code Playgroud)