>the proble is that claims2_id if the PK of the child table so it wont give me the max(fromdate) for claim_id
>what I need is the max date, the status which goes with this date (and the PK claim2_id) for a given claim_ID
Ah, well, I misunderstood that, but it is obvous, now that you mention it. Then, just replace claims2_id with claims_id. Also, in the second part, you can add additional fields from table Claims2, as required:
select claim_id, max(fromdate) as LastDate;
from claims2;
group by claim_id;
into cursor Temp;
nofilter
select Temp.*, Claims2.Status, Claims2.Claim2_id;
from Temp join Claims2;
on Temp.claim_id = Claims2.claim_id and Temp.LastDate = claims2.FromDate;
into cursor Temp
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)