sql PriceAnalysisChange - RelatóriodaintegraçãodaLoja

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql PriceAnalysisChange - RelatóriodaintegraçãodaLoja相关的知识,希望对你有一定的参考价值。

declare @retailstoreid varchar(18);
declare @taskId numeric(10,0);

set @retailstoreid = 'S1688';

select @taskId = MIN(taskid) from tm.Task where ActionId = 14 and PriceChangeDate > GETDATE() - 1;

--total de items para a loja na staging
select count(distinct itemid) as "Total de Items Integrados" from stra.itempricechange with(nolock) where pricechangedate > getdate() - 1 and retailstoreid = @retailstoreid;

--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 = @retailstoreid
						and irs.status in ('A','D')
						and i.itemid in (select itemid from stra.itempricechange with(nolock) where retailstoreid = @retailstoreid and pricechangedate > getdate() -1 and IntegrationStatus = 'P') 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 = @retailstoreid 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 stra.itempricechange with(nolock) where retailstoreid = @retailstoreid and pricechangedate > getdate() -1) 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 = @retailstoreid 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 >= @taskId and actionid = 14 and retailstoreid = @retailstoreid)




-- Valdia se a loja tem alertas
select * from tm.alertconfig ac
inner join tm.Locationlist ll on ac.LocationListId = ll.LocationListId
inner join tm.locationitem li on li.locationlistid=ll.locationlistid
where li.retailstoreid='S1688'

以上是关于sql PriceAnalysisChange - RelatóriodaintegraçãodaLoja的主要内容,如果未能解决你的问题,请参考以下文章

sql GPA - PriceAnalysisChange - Produtos fora dos Alertas

SQL*Plus中怎么执行多个*sql脚本文件

sql 2008和sql 2012的区别

sql [sql技巧]一些sql技巧#sql

sql 2008 r2 在sql 2008上兼容么

SQL基础