Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error correlating fields
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01525783
Message ID:
01525813
Vues:
33
Ok, I stand corrected :) I was not sure it's possible, but I believe your code does exactly what we wanted.

>>No, it will not work. You can not use GROUP BY and relate the fields, AFAIK.
>
>I am sure you can, what I am not sure if it yields the right results as I might have misunderstood the original SELECT, try running the statement yourself and you'll not get an error (EngineBehaviur 90)
>
>
>CREATE CURSOR table1 (setid I, deptid I, effd T)
>CREATE CURSOR table2 (setid I, deptid I, effdt T)
>
>INSERT INTO table1 VALUES (1, 1, DATE() - 2)
>INSERT INTO table1 VALUES (1, 2, DATE() - 2)
>
>INSERT INTO table2 Values(1, 1, DATE() - 4)
>INSERT INTO table2 Values(1, 1, DATE() - 3)
>INSERT INTO table2 Values(1, 1, DATE() - 2)
>INSERT INTO table2 Values(1, 1, DATE() - 1)
>INSERT INTO table2 Values(1, 1, DATE() - 0)
>
>
>SELECT		Table1.*, ;
>		A.*, ;
>		Table2.* ;
>	FROM	Table1 ;
>	LEFT	OUTER JOIN	( ;
>				SELECT		MAX(B.effdt) as maxeffdt, ;
>						B.SetID, ;
>						B.DeptID ;
>					FROM	Table2 B ;
>					WHERE	B.effdt < Table1.effd ;
>					GROUP	BY B.SetID, B.DeptID ;
>			) A ON Table1.setid = A.setid AND Table1.deptid = A.deptid ;
>	LEFT	OUTER JOIN Table2 ON Table1.setid = Table2.setid AND Table1.deptid = Table2.deptid AND Table2.effdt = A.maxeffdt
>
>
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform