Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GROUP BY on ORDER BY
Message
De
15/07/2000 17:51:09
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00392909
Message ID:
00392934
Vues:
7
>If no aggregate function ise used (e.g. SUM, COUNT) then VFP will return the value contained in the last record physically in the table that adheres to the GROUP BY clause. As Marek suggested, use the MAX function to return the highest date in the group:
>SELECT MASTER.MASTERKEY,MAX(CHILD.DATE) AS CHILDDATE FROM CHILD;
>   INNER JOIN MASTER ON CHILD.MASTERKEY=MASTER.MASTERKEY;
>   GROUP BY CHILD.MASTERKEY ORDER BY CHILD.DATE DESCENDING;
>   INTO CURSOR TEMP
>This will return:
>
>000001 01/01/2000
>000002 01/01/2000

Thanks, that works.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform