Skip to content

QA Point in time count

clancyjane edited this page Oct 17, 2014 · 5 revisions

This is as close as you can get without chopping up episodes for overlapping nondfcs episodes unless you use the table prtl.ooh_point_in_time_child

select count(distinct evt.child)
from base.rptPlacement_events evt
join base.rptPlacement plc on evt.id_removal_episode_fact=plc.id_removal_episode_fact
join ref_last_dw_transfer dw on dw.cutoff_date=dw.cutoff_date
where plc.removal_dt < '2001-01-01'
and iif(plc.[18bday] < plc.discharge_dt 
        and plc.[18bday] <= cutoff_date,plc.[18bday],plc.discharge_dt) >='2001-01-01'
and not exists(select * from vw_nondcfs_combine_adjacent_segments nd
                where nd.id_prsn=evt.child
                and  '2001-01-01' between nd.cust_begin and nd.cust_end)
and evt.begin_date <= '2001-01-01'
and evt.end_date>='2001-01-01'
and plc.age_at_removal_mos < (18*12)

Clone this wiki locally