我必须提取一个数据,其中列出了一个月内未见过的所有孩子的名单。数据集中的每一行代表一个联系事件。我有两个程序 - 拉出所有满足“接触满足”标准的接触事件,一个带回所有其他不符合接触标准的接触事件。我需要的清单是所有孩子至少一次没有达到联系标准。
这是我开始的一个数据集:
Child_Name Unit Contact_Date Contact_Method Contact_Result Participant
Chiddick P5J 5/17/2013 Face To Face Contacted No
Chiddick P5K 5/1/2013 Phone Contacted No
Chiddick P5K 5/2/2013 Phone Contacted No
Chiddick P5K 5/3/2013 Face To Face Attempted No
Chiddick P5K 5/6/2013 Phone Contacted No
Chiddick P5K 5/7/2013 Face To Face Attempted No
Melgar P5F 5/13/2013 Face To Face Attempted Yes
Melgar P5F 5/13/2013 Phone Attempted Yes
Melgar P5F 5/15/2013 Face To Face Attempted Yes
Silva P5G 5/8/2013 Face To Face Attempted No
Silva P5G 5/31/2013 Face To Face Attempted No
Bennett P5E 5/1/2013 No Contact No Contact
Bennett P5E 5/8/2013 Face To Face Contacted Yes
Bennett P5E 5/17/2013 Face To Face Contacted Yes
Abreu P5G 5/14/2013 Face To Face Contacted Yes
Abreu P5G 5/29/2013 Face To Face Attempted Yes
此查询适用于遇到的联系人事件:
SELECT
Child_Name,
Unit,
Contact_Date,
Contact_Method,
Contact_Result,
Participant
FROM [DimContacts_Child]
where Unit in('P5C','P4C','P5L','P5D','P5F','P5G','P5E','P5A','P5K','P5J')
and (Contact_Date>='2013-05-01' AND Contact_Date <='2013-05-31')
and **(Contact_Method ='Face To Face')AND (Contact_Result<>'Attempted')AND (Participant='Yes');**
结果:
Child_Name Unit Contact_Date Contact_Method Contact_Result Participant
Bennett P5E 5/8/2013 Face To Face Contacted Yes
Bennett P5E 5/17/2013 Face To Face Contacted Yes
Abreu P5G 5/14/2013 Face To Face Contacted Yes
此查询是未满足的联系事件:
SELECT
Child_Name,
Unit,
Worker_Name
Contact_Date,
Contact_Method,
Contact_Result,
Participant
FROM DimContacts_Child]
where Unit in('P5C','P4C','P5L','P5D','P5F','P5G','P5E','P5A','P5K','P5J')
and (Contact_Date>='2013-05-01' AND Contact_Date <='2013-05-31')
and **not** **((Contact_Method='Face To Face')AND (Contact_Result<>'Attempted')AND (Participant='Yes'));**
结果:
Child_Name Unit Contact_Date Contact_Method Contact_Result Participant
Chiddick P5J 5/17/2013 Face To Face Contacted No
Chiddick P5K 5/1/2013 Phone Contacted No
Chiddick P5K 5/2/2013 Phone Contacted No
Chiddick P5K 5/3/2013 Face To Face Attempted No
Chiddick P5K 5/6/2013 Phone Contacted No
Chiddick P5K 5/7/2013 Face To Face Attempted No
Melgar P5F 5/13/2013 Face To Face Attempted Yes
Melgar P5F 5/13/2013 Phone Attempted Yes
Melgar P5F 5/15/2013 Face To Face Attempted Yes
Silva P5G 5/8/2013 Face To Face Attempted No
Silva P5G 5/31/2013 Face To Face Attempted No
Bennett P5E 5/1/2013 No Contact No Contact
Abreu P5G 5/29/2013 Face To Face Attempted Yes
如果您注意到 Bennett 和 Abreu 是唯一满足联系标准的孩子,则在该月至少会面一次。我需要的是一份在所有接触事件中至少有一次不满足标准的孩子名单。
这就是我需要的:
Child_Name Unit
Chiddick P5J
Melgar P5F
Silva P5G
这三个孩子至少有一次不符合要求。我不知道如何为此修改查询。任何帮助表示赞赏!谢谢!