Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MAX() group by in SQL?
Message
From
01/11/2004 16:51:14
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
MAX() group by in SQL?
Environment versions
Visual FoxPro:
VFP 8
OS:
Windows 2000 SP3
Network:
Windows NT
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00956733
Message ID:
00956733
Views:
39
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?
Next
Reply
Map
View

Click here to load this message in the networking platform