Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql to group two fields
Message
De
22/12/2004 18:53:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00971645
Message ID:
00971649
Vues:
14
I think you can do this in two steps, something like this:
select Grp, max(Date) as Date;
  from MyTable;
  into cursor Temp;
  nofilter

select Temp.*, MyTable.Value;
  from Temp join MyTable;
    on Temp.Grp = MyTable.Grp and Temp.Date = MyTable.Date;
  into cursor Temp
>Is there a way to do an SQL statemrent to group as follows:
>
>File has 3 fields
>
>Grp Date Value
>--- ---- -----
>CC 19/01/04 87
>CC 16/01/04 84
>AA 20/01/04 20
>AA 25/01/04 40
>AA 22/01/04 60
>BB 18/01/04 12
>BB 16/01/04 89
>BB 15/01/04 33
>
>I need to get The latest date for each group
> So the following should be returned in order by Group, but just returning One group
>
>AA 25/01/04 20
>BB 18/01/04 12
>CC 19/01/04 87
>
>Any helpo appreciated
>
>regards,
>Gerard
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)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform