1 2 3 4 5 6 7 8 9 10 11 12 13
|
select CATEGORIE, ARTICLE, ARTICLE_NAME, MAGAZIN,
count(jour) as days_on_prom
into temp_daysOnProm
from (
select distinct CATEGORIE, Hs.ARTCILE, P.ARTICLE_NAME, S.prom_id, S.prom_st_date, S.magazin, JOUR, prom_end_date
from prod P
inner join VENTES Hs on Hs.ARTICLE = P.ARTICLE
inner join PromotionArticle S on S.ARTICLE = P.ARTICLE and s.magazin = Hs.magazin
inner join PromotionHeader Ph on S.prom_id = Ph.prom_id and S.prom_st_date = Ph.prom_st_date and S.magazin = Ph.magazin
where convert(numeric(10,2), volume) > 0 ) K
where K.day between K.prom_st_date and K.prom_end_date
group by CATEGORIE, ARTICLE, ARTICLE_NAME, MAGAZIN |
Partager