Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update command
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01204126
Message ID:
01204200
Views:
18
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform