Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql statement to get value from table
Message
From
06/07/2004 09:09:13
 
 
To
06/07/2004 08:46:40
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00920978
Message ID:
00920985
Views:
21
Hilmar - the group by policyNum,eff_date gets you a record for each policy number and eff_date.I only want the latest effective date. I played with it some more and here is what I ended up with. It breaks SQL convention but it seems to works.
SET ENGINEBEHAVIOR 70
SELECT  policyNum, Rate, MAX(Eff_Date)  FROM xxxxx  GROUP BY policyNum   ;
INTO CURSOR xxxxx 
SET ENGINEBEHAVIOR 80
Thanks
Gaylen




>>I am having a brain cramp. Been working on this too long this morning so I am seeking help
>>
>>Table with 3 value = policy #, rate, eff_dt_rate.
>>
>>I need to extract the policy #'s and rate that is associated with latest eff_date for each policy into a separate table.
>>
>>Thanks
>>Gaylen
>
>Methinks you can first get the latest date for each policy, something like:
>
>
>select PolicyNum, max(Eff_Date) as Eff_Date;
>  group by PolicyNum, Eff_Date;
>  into cursor Temp1 NoFilter
>
>
>(I never tried using max() with dates, though.)
>
>Then, join this with the original table, to get the Rate. Watch out for duplicates - you may want to use GROUP BY once more.
>
>HTH,
>
>Hilmar.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform