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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in building this query... 2

Status
Not open for further replies.

thelordoftherings

Programmer
May 16, 2004
616
IL
Hello,

I have a table containing this sort of a data:

ID DATE
123 1/1/2005
456 1/4/2006
123 7/5/2005
789 11/10/2002
789 6/7/2001
123 1/12/2003
....

I would like to create a query which will output for each ID it's latest date available. For example, for the data above the query results will be:
123 7/5/2005
456 1/4/2006
789 11/10/2002
...

Can anyone please help me build such a query?
 
Select ID, MAx(Date)
From Table
Group By ID
Order By Id

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Code:
SELECT Id, MAX(Date) AS Date
FROM MyTable
GROUP BY Id

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top