--Total de Items Integrados via Ficheiro
select count(distinct itemid) as "Total de Items Integrados via Ficheiro" from intf.st_in_gama with(nolock) where ctrl_data > getdate() - 1 and retailstoreid = '8';
--Total de Items Elegíveis (alteração nome/descrição ou preço)
select count(distinct itemid) as "Total de Items Elegíveis (alteração nome/descrição ou preço)" from ra.itemretailstore with(nolock) where lastpricechange > getdate() - 1 and retailstoreid = 'S0008';
--total de items com alerta configurado
select count(distinct i.itemid) as "Total de Items Ativos e com Alerta Configurado"
from ra.item i with(nolock)
join ra.itemretailstore irs with(nolock) on irs.itemid = i.itemid
where irs.retailstoreid = 'S0008' and irs.status in ('A','D') and irs.lastpricechange > getdate() - 1 and hierarchicalstructureid in (
SELECT DISTINCT hsp.HierarchicalStructureId
FROM ra.HierarchicalStructurePath hsp with(nolock)
INNER JOIN ra.BusinessStructureItem bsi with(nolock) ON bsi.HierarchicalStructureId = hsp.HierarchicalAncestorId
WHERE bsi.BusinessStructureListId in (
select a.businessstrucutureid from tm.alertconfig a with(nolock)
join tm.locationitem li with(nolock) on li.locationlistid = a.locationlistid
where li.retailstoreid = 'S0008' and a.status in ('A','W')
)
);
-- total de items sem alerta configurado
select count(distinct itemid) as "Total de Items sem Alerta Configurado"
from ra.item with(nolock)
where itemid in (select itemid from ra.itemretailstore with(nolock) where lastpricechange > getdate() - 1 and retailstoreid='S0008')
and hierarchicalstructureid not in (
SELECT DISTINCT hsp.HierarchicalStructureId
FROM ra.HierarchicalStructurePath hsp with(nolock)
INNER JOIN ra.BusinessStructureItem bsi with(nolock) ON bsi.HierarchicalStructureId = hsp.HierarchicalAncestorId
WHERE bsi.BusinessStructureListId in (
select a.businessstrucutureid from tm.alertconfig a with(nolock)
join tm.locationitem li with(nolock) on li.locationlistid = a.locationlistid
where li.retailstoreid = 'S0008' and a.[status] IN ('A','W')
)
);
-- total de items na tarefa
select count(distinct itemid) as "Total de Items nas Tarefas"
from tm.taskitem with(nolock)
where taskid in(select TaskId from tm.Task with(nolock) where TaskId >= (select MIN(taskid) from tm.Task where ActionId = 14 and createdate > GETDATE()-1) and actionid = 14 and retailstoreid = 'S0008')