Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GROUP BY on ORDER BY
Message
From
15/07/2000 17:51:09
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00392909
Message ID:
00392934
Views:
9
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform