leohickstein
5/11/2017 - 5:53 PM

Identificar Produtos PriceChange Que Geraram Tarefas

Identificar Produtos PriceChange Que Geraram Tarefas

select ipc.ItemId, ipc.IntegrationDate, ipc.RetailStoreId, ac.Description, a.Name, a.CreateDate, t.Description, t.CreateDate
from stra.ItemPriceChange ipc
inner join ra.item i on i.ItemId = ipc.ItemId
inner join tm.LocationItem li on li.RetailStoreId = ipc.RetailStoreId
inner join tm.LocationList ll on ll.LocationListId = li.LocationListId
inner join tm.AlertConfig ac on ac.LocationListId = ll.LocationListId
left join tm.Alert a on a.AlertConfigurationId = ac.AlertConfigId
left join tm.Task t on t.AlertId = a.AlertId
where ipc.RetailStoreId = 'S2124' and ipc.IntegrationDate between '2017-05-11 00:00:00' and '2017-05-11 07:30:00' and
i.HierarchicalStructureId IN 
    (
        SELECT HierarchicalStructureId FROM ra.HierarchicalStructurePath WHERE HierarchicalAncestorId IN (
        SELECT HierarchicalStructureId FROM ra.BusinessStructureItem WHERE BusinessStructureListId=ac.BusinessStrucutureId)
    ) 
	and a.CreateDate > '2017-05-11 00:00:00'
	and t.CreateDate > '2017-05-11 00:00:00'