Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select 2 fields plus max(field)
Message
De
06/03/1998 12:17:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00083033
Message ID:
00083050
Vues:
21
>>>>I need to select 3 fields from 1 table, but the 3rd field is a max(actiondate). First field is a non-unique ID (many records per ID), the second field is ActionType. I need the record that has the most recent ActionDate for each ID, including the ActionType field. For the life of me, I can not figure out how do this in a SQL statement. There is probably a subquery involved, but I can't figure out how to code it. Anyone got a solution? Something that starts with:
>>>>Select ID, ActionType, Max(ActionDate) as "ActDate" ;
>>>>   from Transacts ....
>>>>TIA.
>>>Mark maybe I'm missing something but adding a "group by actiondate" seem sufficient to me.
>>>Cetin
>>Oops it would be "group by ID" and then I think you also don't need max() if actiondate is in entered sequentially by date.
>>Cetin
>
>Group by ID works only if ActionDate is entered sequentially. Unfortunately, I am looking for something that works regardless of sequence of entry. A local view that orders by ID, ActionDate looks like the easiest solution. Then I could run the query against the view.
It would work if not entered sequentially too. Just use max() then.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform