Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error correlating fields
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01525783
Message ID:
01525811
Views:
37
>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
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform