var query = $@"from ""event""
where Payload.identifiers.subject_id != null
and Payload.identifiers.subject_id in ({ids})
and Header.Name in ('territory_entry', 'territory_exit')
and Payload.time_stamp between '{dateStart}' and '{dateEnd}'
select distinct Payload.identifiers";