Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Problem
Message
De
14/06/1999 11:46:19
 
 
À
14/06/1999 11:17:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00229451
Message ID:
00229466
Vues:
24
>Please help me to write following sql. I am confused about how
>to get it.
>following is a problem and the sample data set
>
>code cparentid ddate cdesc
>
>01 10 01/01/99 ABC
>02 10 05/01/99 DEF
>03 10 03/01/99 PQR
>04 20 04/01/99 PPP
>05 20 06/01/99 KOP
>06 20 03/01/99 RAP
>
>Now, I want to get the details of that record which has highest
>date in every group.(cparentid)
>
>for example,
>for group of cparentid = 10 the highest date would be 05/01/99
>for group of cparentid = 20 the highest date would be 06/01/99
>
>so I need two records in my result set
>
>code cparentid ddate cdesc
>02 10 05/01/99 DEF
>05 20 06/01/99 KOP
>
>Please help me with above query as I am stuck on it and don't know
>how to solve it.
>
>Thank you in advance
>
>Thanks
>Mark

I would do this to obtain those records

select cid, ;
max(date) as MaxDate ;
from table1 ;
group by campo2 into cursor Tempo1


Then I woud do a join with the original table to complete the needed fields.

Note that the field Date is no what you expect if you include it into the first query.

Oscar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform