-- ResponseHistory update "template"
ALTER TABLE HH_ResponseHistory ADD DirectResponse int NULL
go
-- Update the treatment sizes
update ua_treatment
set treatmentsize=(select count(DISTINCT HouseholdID)
from HH_ContactHistory
where HH_ContactHistory.CellID = ua_treatment.CellID
AND HH_ContactHistory.PackageID = ua_treatment.PackageID
and ua_treatment.CntrlTreatmtFlag = 1 and ua_treatment.HasDetailHistory = 0)
where exists
(select * from hh_contacthistory
where hh_contacthistory.CellID = ua_treatment.CellID
AND hh_contacthistory.PackageID = ua_treatment.PackageID
and ua_treatment.CntrlTreatmtFlag = 1 and ua_treatment.HasDetailHistory = 0)
go
update ua_treatment
set treatmentsize=(select count(DISTINCT HouseholdID)
from HH_DtlContactHist
where HH_DtlContactHist.TreatmentInstID = ua_treatment.TreatmentInstID
and ua_treatment.CntrlTreatmtFlag = 1 and ua_treatment.HasDetailHistory = 1)
where exists
(select * from hh_dtlcontacthist
where hh_dtlcontacthist.TreatmentInstID = ua_treatment.TreatmentInstID
and ua_treatment.CntrlTreatmtFlag = 1 and ua_treatment.HasDetailHistory = 1)
go
Copyright IBM Corporation 2015. All Rights Reserved.
|