roberto
3/26/2018 - 9:41 PM

Estrazioni PK+MARKET per CNH CE+NH

Estrazione delle combinazioni PK + Market da profilo per fare caricamento prezzi costi ecc

--SELECT TOP 100
-- Po.*
--,Pk.*
--,Sb.*
--,Br.*
--,Hm.*
-- select count(*)
-- select sum(Po.WholesaleQuantity)
-- select count(*)
select
 Po.YearMonthId
,Pk.PlanningKeyCode
,Hm.HfmMarketCode
,Po.WholesaleQuantity
,Br.BrandName
--select sum(Po.WholesaleQuantity)
FROM [CWFPQA].[dom].[PO] Po
inner join dom.PlanningKey Pk on (Pk.PlanningKeyId = Po.PlanningKeyId)
inner join dom.SubBrand Sb on (Sb.SubBrandId = Pk.SubBrandId)
inner join dom.Brand Br on (Br.BrandId = Sb.BrandId)
inner join dom.Market Mk on Mk.MarketId = Po.MarketId
inner join dom.CwfpMarket Cm on Cm.MarketId = Mk.MarketId
inner join dom.HfmMarket Hm on ((Hm.CwfpMarketId = Cm.CwfpMarketId) and (Hm.DefaultHfmMarket = 1))
where
(Po.SopPlanId = 20180204)
and ((Po.YearMonthId / 100) = 2018)
-- and (Br.BrandId in (335736,335737))
and (Br.BrandId in (335739))
order by 3,2,1