-
Notifications
You must be signed in to change notification settings - Fork 0
SQL OOH Point In Time Race
clancyjane edited this page Sep 23, 2014
·
2 revisions
-- this is the table all point in time measures come from
select cd_race_census ,count(distinct id_prsn_child) from prtl.ooh_point_in_time_child
where point_in_time_date='2011-01-01'
and date_type=2 and qry_type=2
group by cd_race_census
order by cd_race_census
-- this is CA table
select rp.cd_race_census,count(distinct plc.child) from base.rptPlacement_Events plc
join base.rptPlacement rp on rp.id_removal_episode_fact=plc.id_removal_episode_fact
join ref_last_dw_transfer dw on dw.cutoff_date=dw.cutoff_date
where rp.removal_dt < '2011-01-01'
and iif( rp.[18bday] < rp.discharge_dt
and rp.discharge_dt<=cutoff_date,rp.[18bday],rp.discharge_dt)>='2011-01-01'
and plc.begin_date <='2011-01-01' and plc.end_date>='2011-01-01'
and not exists (select * from vw_nondcfs_combine_adjacent_segments nd
where nd.id_prsn=rp.child
and rp.removal_dt between nd.cust_begin and nd.cust_end
and rp.discharge_dt between nd.cust_begin and nd.cust_end )
and rp.age_at_removal_mos < 12*18 and rp.age_at_removal_mos >=0
group by rp.cd_race_censusThese do not match exactly as in the top table, the episodes are "spliced" removing the "nondcfs" segments.