Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pull distinct records but based on highest std and stdve
Message
De
01/08/2005 17:18:55
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01037631
Message ID:
01037645
Vues:
26
Thanks Martin!

>Hi Tracy,
>
>
>SELECT Grpid,Grpver,Ref,Len,Descriptio from table where grpver IN;
> (SELECT max(aa.Grpver) from table aa group by aa.grpid where aa.grpid=table.grpid)
>
>SELECT Grpid,Grpver,Ref,Len,Descriptio from table,;
> (SELECT grpid,max(Grpver) from table group by grpid) AA ;
>  where table.grpid=aa.grpid
>
>
>MartinJ
>
>>Don't know if this can be done, but here goes. Given the below structure and example data:
>>
>>Grpid  Grpver   Ref    Len Descriptio
>>
>>ODDE      1     POLNO  25  Policy Number
>>ODDE      2     POLNO  25  Policy Number
>>ODDE      3     POLNO  25  Policy Number
>>ODDT            DDCDL   3  Code Length
>>ODDT      1     DDCDL   3  Code Length
>>ODDT      2     DDCDL   4  Code Length
>>6SBC            CANCL   2  Cancel Days
>>6SBC      1     CANCL   2  Cancel Days
>>6SBC      2     CANCL   3  Cancel Days
>>
>>I want to select distinct records for the ref field but I always want the highest Grpid+Grpver value. So in the above example the query result would be 3 records:
>>
>>ODDE      3     POLNO  25  Policy Number
>>ODDT      2     DDCDL   4  Code Length
>>6SBC      2     CANCL   3  Cancel Days
>>
>>Because ODDE 3 and ODDT 2 and 6SBC 2 are the highest grpver's for each grpid. Can this be done?
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform