Sie sind auf Seite 1von 2

adbactive:

sql
select pal.Person_id FROM adbmore.dbo.Person_Activity_Level pal
INNER JOIN ( SELECT person_id ,
MAX(Start_date) start_date
FROM adbmore.dbo.Person_Activity_Level pl
WHERE pl.Activity_Level
LIKE '%ll%'
GROUP BY Person_id
) a ON pal.Person_id = a.person_id
AND a.START_DATE = pal.start_date
WHERE activity_level IN ( 'LL00', 'LL01', 'LL03', 'LL06', 'LL12' );

ctgt:
sql select DISTINCT ska_matched_id skaid FROM clinician_match.dbo.client_ta
rget ct INNER JOIN Clinician_Match.dbo.Access_Target_Metadata atm ON ct.Target_l
ist_version_name = atm.Target_List_Version_Name
WHERE event_type='access' AND mailing_list_target=1;
skaPrelim:
sql SELECT skp.persid ,
zip5 ,
CASE WHEN Is_Access_Target = 1
AND year = YEAR(GETDATE()) THEN 1
ELSE 0
END AS 'Access target' ,
CASE WHEN at.practitioner IS NOT NULL THEN 1
ELSE 0
END AS 'Present On Wkh' ,
CASE WHEN sam.person_id IS NOT NULL THEN 1
ELSE 0
END AS 'Alumni' ,
CASE WHEN aa.person_id IS NOT NULL THEN 1
ELSE 0
END AS 'active alumni' ,
CASE WHEN ct.skaid IS NOT NULL THEN 1
ELSE 0
END AS 'Client_target'
FROM adbmore..ska_phy skp
LEFT OUTER JOIN adbmore.dbo.wkh_ska_map wsm ON skp.persid =
wsm.persid
LEFT OUTER JOIN adbmore.dbo.All_Targets at ON wsm.Practitio
ner = at.Practitioner
AND at.Year = YEAR(GE
TDATE())
LEFT OUTER JOIN adbmore.dbo.ska_adb_map sam ON skp.persid =
sam.ska_person_id
LEFT OUTER JOIN resident adbactive adb aa ON sam.person_id =
aa.person_id
LEFT OUTER JOIN resident ctgt ct ON skp.persid = ct.skaid;
ska:
select t.* ,
CASE WHEN client_target = 1
OR [Access TARGET] = 1 THEN 1
ELSE 0
END AS 'Target' ,
CASE WHEN Alumni = 1
AND [active alumni] = 1 THEN 'Active Alumni'
WHEN alumni = 1
AND [active alumni] = 0 THEN 'Inactive Alumni'
WHEN [present on wkh] = 1
AND alumni = 0 THEN 'WKH'
ELSE 'SKA'
END AS 'Category'
FROM resident skaPrelim;
/*
STORE ska INTO ../QVD/ska.QVD;

Client_target:
load Client_product ,
Client_product_parent ,
client_target_id ,
target_list_version_name ,
adb_person_id ,
practitioner ,
ska_matched_id ,
master_id
FROM Clinician_Match.dbo.client_target
WHERE Target_list_version_name IN ( 'amgen_oct_2009', 'novo_feb_2010',
'januvia_jan_2010', 'vytorin_jan_2010',
'zipsor_feb_2010', 'merck_dec_2010' );
STORE Client_target INTO ../QVD/ClientTarg
et.QVD;
client_event:
load account_product_list,dim.event_code FROM adbmore.dbo.ra_Dim_na_Activity di
m
inner JOIN adbmore.dbo.vw_dim_event vde
ON vde.event_code=dim.event_code
INNER JOIN Clinician_Match.dbo.Access_Target_Metadata atm
ON atm.Account_Product=dim.Account_Product_List
AND atm.year=vde.event_year
WHERE event_group_name='access'
and event_year=year(getdate())
AND account_product_list IS NOT NULL
ORDER BY account_product_list;
STORE client_event INTO ../QVD/ClientEvent.QVD;

*/