What we have here is that the column is_initial_event we have coded that only the people_id that have only '1' value in is_initial_event (not 0 and 1) we want, But I also need the ones that are null - how can I fold in the Null requirement in the partition?
select *
from (
select
ac.Full_name,
pe.program_start_date,
pe.program_end_date,
tp.approved_by_Description as Approved,
ev.is_initial_event,
tp.staff,
min(ev.is_initial_event + 0) over(partition by ac.people_id) min_initial_event
from all_clients_view ac
inner join program_enrollment_expanded_view pe
on ac.people_id = pe.people_id
inner join service_plan_goals_objectives_methods_view tp
on ac.people_id = tp.people_id
inner join service_plan_event_view ev
on ac.people_id = ev.people_id
where
pe.program_name = 'CFTSS'
and tp.Approved_by_description is null
) t
where min_initial_event = 1
order by full_name