Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Bonjour,
J'avance pas à pas par rapport à ma question précédente mais j'ai à nouveau besoin de votre aide :
J'ai une table Commandes _Packs qui contient des champs suivants :
CommandePack | IndicatifPack | CodepromoPack |
---|---|---|
111111 | AAAA | PACK_REUSS |
222222 | BBBB | PACK_AVANT |
333333 | CCCC | PACK_REUSS |
Ma table 'Inscriptions' avec une multitude de champs dont un CodePromo pour certains indicatifs
AAAA | |
GGGG | 50 |
EEEE | 58 |
BBBB |
Je veux rapatrier dans la seconde table les informations du champ CodePromoPack dans le champ CodePromo pour les Indicatifs présents dans la première table et conserver les CodePromo déjà présents.
Indicatif | CodePromo |
---|---|
AAAA | PACK_REUSS |
GGGG | 50 |
EEEE | 58 |
BBBB | PACK_AVANT |
J'ai essayé différents join mais je n'ai pas réussi.
Merci
Anne
RESULT
SCRIPT
a:
load * inline [
CommandePack, IndicatifPack, CodepromoPack
111111, AAAA, PACK_REUSS
222222, BBBB, PACK_AVANT
333333, CCCC, PACK_REUSS
];
b:
load * inline [
Indicatif, CodePromo
AAAA,
GGGG, 50
EEEE, 58
BBBB,
];
map:
mapping load IndicatifPack, CodepromoPack resident a;
final:
NoConcatenate
load
Indicatif, ApplyMap('map', Indicatif, CodePromo) as CodePromo
Resident b;
drop table b;
TAB1:
LOAD * Inline [
CommandePack, IndicatifPack, CodepromoPack
111111, AAAA, PACK_REUSS
222222, BBBB, PACK_AVANT
333333, CCCC, PACK_REUSS
];
TAB2:
LOAD * Inline [
Indicatif, CodePromo
AAAA,
GGGG, 50
EEEE, 58
BBBB,
];
MYTABTMP:
NoConcatenate
LOAD Indicatif, CodePromo Resident TAB2;
left join
LOAD IndicatifPack as Indicatif, CodepromoPack as tmpFld Resident TAB1;
DROP Tables TAB1, TAB2;
Bonjour,
J'ai essayé avec votre code mais ça ne fonctionne pas : les libellés "PACK" ne sont pas rapatriés dans le champ Code_statistique. Je vous met ci-dessous la totalité du code :
CommandesPacks:
LOAD distinct
Commande as CommandePack,
`Code Produit` as CodeProduitPack
resident Ecommerce
WHERE WildMatch(`Code Produit`, '*PACK*');
IndicatifPacks:
LOAD
Commande as CommandePack,
AnnéeSiteIndicatif as IndicatifsPacks
resident Ecommerce
WHERE Exists([CommandePack],[Commande]);
Outer join (CommandesPacks)
LOAD
CommandePack,
IndicatifsPacks
resident IndicatifPacks;
MYTABTMP:
NoConcatenate
LOAD
AnnéeSiteIndicatif,
Code_statistique
Resident Inscriptions;
left join
LOAD IndicatifsPacks as AnnéeSiteIndicatif,
CodeProduitPack as tmpFld
Resident CommandesPacks;
DROP Tables CommandesPacks, TAB2;
DROP Table WSBEL;
DROP Table IndicatifPacks;
Merci
Anne
Bonjour,
Ça fonctionne presque avec votre solution...sauf que maintenant chaque indicatif a deux codes promos alors que je veux que le premier code soit remplacé par le deuxième.
Voici le script tel que je l'ai rédigé :
ListeCommandesPacks:
LOAD distinct
Commande as Commande_Pack,
`Code Produit` as Code_Produit_Pack
resident Ecommerce
WHERE WildMatch(`Code Produit`, '*PACK*');
ListeIndicatifsPacks:
LOAD
Commande as Commande_Pack,
AnnéeSiteIndicatif as Indicatif_Pack
resident Ecommerce
WHERE Exists([Commande_Pack],[Commande]);
Outer join (ListeCommandesPacks)
LOAD
Commande_Pack,
Indicatif_Pack
resident ListeIndicatifsPacks;
Tmp_Inscriptions:
LOAD
AnnéeSiteIndicatif,
Code_statistique
Resident Inscriptions;
map:
mapping load Indicatif_Pack, Code_Produit_Pack resident ListeCommandesPacks;
Final:
NoConcatenate
load
AnnéeSiteIndicatif, ApplyMap('map', AnnéeSiteIndicatif,Code_statistique) as Code_statistique
Resident Tmp_Inscriptions;
DROP table Tmp_Inscriptions;
DROP Table WSBEL;
DROP Table ListeIndicatifsPacks;
DROP Tables ListeCommandesPacks;
Commandes _Packs:
mapping load
IndicatifPacks as Indicatif ,
CodepromoPacks
from 'Commandes _Packs';
Inscriptions:
load
Indicatif,
Applymap( 'Commandes _Packs', Indicatif, Codepromo) as Codepromo
from 'Inscriptions table';