Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update command
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
01204126
Message ID:
01204200
Vues:
16
First join is incorrect if you have multiple previous records.

>Naomi,
>
>
>You are right.
>
>
> UPDATE ap ;
>    SET nstock = pd.nstock ;
>    FROM Agenda ap;
>    JOIN (;
>    SELECT ag.nstock, ag.iid FROM Agenda ag WHERE ag.ddate < (vp_date) ;
>    UNION ALL ;
>    SELECT T.nstock, dt1.iid ;
>    FROM ( ;
>    SELECT iid,itraiterId ;
>    FROM Agenda ag2 ;
>    WHERE ddate = (vp_date) ;
>    AND NOT EXISTS (SELECT * FROM Agenda ag3 ;
>    WHERE ag3.ddate < (vp_date) ;
>    AND ag3.iid  = ag2.iid) ;
>    ) dt1 ;
>    JOIN Traiter T ON T.iid = dt1.itraiterId 	;
>    ) pd ON ap.iid = pd.iid ;
>    WHERE ap.ddate = vp_date
>
>
>Give a good result
>
>bernhart
>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform