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!

Latest date query

Status
Not open for further replies.

theog

Programmer
May 1, 2001
13
US
Hi & thanks in advance for any assistance...

In a simple asset db, I have an 'event' table that deals with events related to each asset. Each record in the event table has an asset serial number and a date/time associated with each event. There are duplicates of serial numbers in the table, but their associated event date/times are all different.

I want to formulate a query to return the serial number, and only the latest date/time associated with that serial number. By way of simplified example (time removed for simplicity), if the table looks like this:

Asset SN Date/Time
1 1/1/01
1 2/2/01
1 3/3/01
2 1/1/01
2 2/2/01


I want the query result to return only:

Asset SN Date/Time
1 3/3/01
2 2/2/01

Can this be done? I can't figure it out...

 
select [Asset SN], max(yourdate)
From yourtable
Group by [Asset SN]
 
Well that's just slicker than snot on a marble! I knew it'd be something simple like that, I just couldn't figure it out.

A thousand Thank You's...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top