1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
drop table olap01;
SELECT
tra.idTransaction
, tra.ArticleQty
, tra.NetAmount
, sto.idStore
, sto.Country
, sto.Region
, sto.City
, sto.CompanyName
, sto.StoreName
, sto.StoreGroup
, sto.StoreType
, sto.LocationType
, sto.PostCode
, sto.RetailerID
, sto.RetailerStore
, tab.idDate
, tab.ComputerDate
, tab.SqlDate
, tab.Annee
, tab.Mois
, tab.AnneeMois
, tab.Jour
, tab.Quarter
, tab.YearQuarter
, tab.Semaine
, tab.AnneeSemaine
, case tab.DayWeek
WHEN 'Mon' THEN 'Lundi'
WHEN 'Tue' THEN 'Mardi'
WHEN 'Wed' THEN 'Mercredi'
WHEN 'Thu' THEN 'Jeudi'
WHEN 'Fri' THEN 'Vendredi'
WHEN 'Sat' THEN 'Samedi'
WHEN 'Sun' THEN 'Dimanche'
END as DayWeek
, tab.Worked
, sal.Qty
, sal.NetAmount AS salesnetamount
, sal.BrutAmount AS salesbrutamount
, art.idArticle, art.Ref
, art.Description
, art.idBrand
, art.Brand
, art.idFamily
, art.Family
, art.Parkod
, lin.idLine
, lin.Line
, axe.IDAxe
, axe.AxeName
, axe.ShortName
, fami.idFamille
, fami.libFamille
, sof.idSousFamille
, sof.libSousFamille
, cate.idCategory
, cate.Category
, art.CreationDate
, datediff(Month
, SUBSTRING(CAST(art.CreationDate AS char ) ,7 ,2) + '/' + SUBSTRING(CAST(art.CreationDate AS char ) ,5 ,2) + '/' + SUBSTRING(CAST(art.CreationDate AS char ) ,1 ,4)
, SUBSTRING(CAST(sal.idDate AS char ) ,7 ,2) + '/' + SUBSTRING(CAST(sal.idDate AS char ) ,5 ,2) + '/' + SUBSTRING(CAST(sal.idDate AS char ) ,1 ,4)
)
as ageEnMois
, dep.nomDep
INTO OLAP01
FROM salesdwh sal
INNER JOIN tabledate tab ON sal.idDate=tab.idDate
INNER JOIN store sto ON sal.idStore=sto.idStore
INNER JOIN art art ON sal.idArticle=art.idArticle
INNER JOIN line lin ON art.idLine=lin.idLine
INNER JOIN axe axe ON lin.idAxe=axe.IDAxe
INNER JOIN transacdwh tra ON sal.IdTransaction=tra.idTransaction
INNER JOIN category cate ON art.idCategory=cate.idCategory
INNER JOIN categoriesousfamille csf ON cate.idCategory=csf.idCategory
INNER JOIN sousfamilles sof ON sof.idSousFamille=csf.idSousFamille
INNER JOIN familles fami ON fami.idFamille=sof.idFamille
INNER JOIN departement dep ON dep.numDep = left(sto.PostCode, 2)
; |
Partager