select distinct HierarchicalStructureId
from [intf].[st_in_gama] g with(nolock)
inner join ra.Item i on i.ItemId = g.ItemId
where g.ctrl_data between '2017-04-25 00:00:00' and '2017-04-25 23:59:59' and i.HierarchicalStructureID not in (
select distinct bli.HierarchicalStructureId
from [tm].[AlertConfig] ac with (nolock)
inner join [ra].[BusinessStructureList] bl on bl.BusinessStructureListId = ac.BusinessStrucutureId
inner join [ra].[BusinessStructureItem] bli on bl.BusinessStructureListId = bli.BusinessStructureListId
where ac.ActionId = 14 and ac.Status='A'
)