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!

Complicated Query 1

Status
Not open for further replies.

Jenns

Programmer
Nov 1, 2000
36
US
I am having trouble trying to query data to return the most current date, per ID. There are multiple records per ID in the table.

Data Example:
ID Date
123 2/28/02
111 1/31/02
123 1/01/02
111 11/30/01
222 5/31/02
222 12/31/01
111 11/30/01

My customer would like to see only the following data:
ID Date
123 2/28/02
111 1/31/02
222 5/31/02

I tried to query using TOP 1 and order by DATE desc to get the most current data. This sort of works but, unfortunatly only returns one record. I need to know the most current date for each ID.

Any thoughts on how do do this?

Thanks,
Jenn Thanks!
Jenn
 
SELECT myID, max(myDate) from myTable GROUP BY myID -- Just trying to help... LOL [ponder]
 
Hey, that's perfect!

Thanks a lot! Thanks!
Jenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top