Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql statement to get value from table
Message
De
06/07/2004 09:09:13
 
 
À
06/07/2004 08:46:40
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00920978
Message ID:
00920985
Vues:
22
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform