Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query only the latest values

Status
Not open for further replies.

gundie

Programmer
Feb 5, 2004
69
US
I have the following in a table named "summary":

Company Date
ABC Auto 9/1/05
ABC Auto 8/17/05
ABC Auto 8/14/05
DEF Auto 4/1/05
DEF Auto 5/16/05
DEF Auto 7/22/05

I want to apply a query to this table to retrieve the latest date for each company. Result from the above table would be:

Company Date
ABC Auto 9/1/05
DEF Auto 7/22/05

How would I do that? Thanks for all help!
 
Code:
SELECT Company, Max([Date]) AS Latest_Date
FROM summary
Group BY Company;

[red]You should avoid using reserved words (like "Date") as field names in your tables![/red]

HTH,
fly

[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
[blue]Database_Systems and _Applications shared across all Business_Areas[/blue]
 
SELECT Company, Max([Date]) As LatestDate
FROM summary
GROUP BY Company

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hey, Martin, You looked over my shoulder ? ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top