Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql: parent - child
Message
From
13/08/2004 04:47:14
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00932653
Message ID:
00933038
Views:
21
Hi Sergey
Thanks a lot. I still have not overcome enginbehavior70-itis <s>

Peter


>Hi Peter,
>
>Your select wouldn't run with SET ENGINEBHAVIR 80 because you didn't define from which records data for table2 columns should come. Try
SELECT t1.signout_id AS id1,;
>		t1.claim_id,;
>		t2.* ;
>	FROM signout t1;
>	JOIN signout2 t2;
>	ON t1.signout_id = t2.signout_id
>	WHERE t2.insdttm IN ( ;
>		SELECT MAX(t2.insdttm) FROM signout2 t22 ;
>			WHERE t22.signout_id = t2.signout_id)
>
>
>>I have a table1 (PK=signout_id) and a table2 (PK=sgnout2_id,FK=signout_id)
>>
>>for each record in table1 I need the last record in table2 (max(insdttm))
>>
>>is the following sql statement reliable:
>>(VFP8 SP1)
>>
>>
>>SELECT table1.signout_id as id1,;
>>table1.claim_id,;
>>  MAX(table2.insdttm),table2.*;
>>  from signout table1;
>>   inner JOIN signout2 table2;
>>   ON table1.signout_id=table2.signout_id;
>>   GROUP BY 1,2
>>
>>
>>the table2.* data must belong to the table2 record with the highest insertdatetime (insdttm)
>>
Peter Cortiel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform