Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MAX() group by in SQL?
Message
De
01/11/2004 16:51:14
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
MAX() group by in SQL?
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows 2000 SP3
Network:
Windows NT
Database:
Visual FoxPro
Divers
Thread ID:
00956733
Message ID:
00956733
Vues:
40
I need to do a SQL SELECT that keeps the ID and I need the last action date. The code to do that is as follows:

SELECT id, MAX(act_dt) FROM tbl GROUP BY id

OK, so far no problem. However, what if there are 10 action dates per ID and I also need to keep two more columns? That is, I need the exact values for the other two columns that correspond to the same row that is on the MAX(act_dt).

How can I be sure that I am getting say row 8 as the MAX date and the other two columns associated with that MAX date are also from the same row 8 not row 1 or 4 or 10?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform