Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql max of one field
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01412746
Message ID:
01412866
Views:
64
Hi Folks, Thanks for all your replies.
I thought I would keep it simple by showing a sample where there were
just two fields... in reality there are more than the two fields.
I note that there is a different solution if there are more than 2 fields !!!
I'll take that into account.

Thanks again
Regartds.
Gerard



>>I have a table as follows with 2 columns :
>>CUS Date (Date field)
>>A 10 May
>>A 12 May
>>A 14 May
>>B 6 Jan
>>B 9 JUN
>>B 20 DEC
>>
>>Is there a Sql select which will select out all customers but with most recent date only
>>So I would require:
>>A 14 May
>>B 20 Dec only
>>
>>Tia
>>Gerard
>
>If you want to get ALL fields (or at least more than just these two) from that table for most recent date, and if you have MORE than just Customer and Date field:
>
>SELECT YourTable.*;
>FROM YourTable;
>INNER JOIN (SELECT Cus, MAX(DATE) AS Date;
>                   FROM YourTable;
>            GROUP BY Cus) Tbl1;
>      ON YourTable.Cus = Tb1l.Cus AND
>         YourTable.Date = Tbl1.Date;
>INTO CURSOR crsTest
>BROWSE NORMAL
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform