Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Max date and status from child table
Message
From
14/01/2005 09:41:26
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
14/01/2005 09:28:38
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00977172
Message ID:
00977188
Views:
19
>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)
Previous
Reply
Map
View

Click here to load this message in the networking platform