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
| select
a.ITMREF_0 as ref_article,
a.ITMDES1_0 as des_article,
a.TCLCOD_0 as categorie,
a.X_TYPVIN_0 as type_vin,
case a.X_COUL_0 when 'R' then 'Rouge' when 'S' then 'Rosé' when 'B' then 'Blanc' when 'X' then 'Indéterminé' end as couleur,
a.X_MILL_0 as millesime,
a.X_FORMAT_0 as format_vin,
t.X_DESVIN_0 as desig_libelle,
a.X_CAPSULE_0 as capsule,
a.X_ETIQ_0 as etiquette,
a.X_ETUI_0 as etui,
a.X_TYPCAIS_0 as type_caisse,
a.X_NBFCDT_0 as contenance,
a.X_RACINE_0 as racine,
a.STU_0 as unite_stock,
a.SAU_0 as unite_vente,
a.SSUSTUCOE_0 as coefficient,
s.QTYSTU_0 as stock_dispo,
sum (g.X_QTEUS_0 - g.X_QTCUMUSL_0) AS gardiennage
FROM
DILLON.ITMMASTER a
INNER JOIN
DILLON.STOCK s
ON a.ITMREF_0 = s.ITMREF_0
INNER JOIN
DILLON.XCDEGARD g
ON a.ITMREF_0 = g.X_ITMREF_0
INNER JOIN
DILLON.XTYPVIN t
ON a.X_TYPVIN_0 = t.X_TYPVIN_0
GROUP BY
a.ITMREF_0
,a.ITMDES1_0
,a.TCLCOD_0
,a.X_TYPVIN_0
,case a.X_COUL_0 when 'R' then 'Rouge' when 'S' then 'Rosé' when 'B' then 'Blanc' when 'X' then 'Indéterminé' end
,a.X_MILL_0
,a.X_FORMAT_0
,t.X_DESVIN_0
,a.X_CAPSULE_0
,a.X_ETIQ_0
,a.X_ETUI_0
,a.X_TYPCAIS_0
,a.X_NBFCDT_0
,a.X_RACINE_0
,a.STU_0
,a.SAU_0
,a.SSUSTUCOE_0
,s.QTYSTU_0 |
Partager