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

Select record with the most recent date

Status
Not open for further replies.

CarolCook

IS-IT--Management
Mar 7, 2003
158
US
Hi:

I have a database that has an entry for a piece of equipment, the date it was moved to a new job and the new job. I need a query which shows where the equipment is now - i.e. the the equipment and the job line with the most recent date.

Select equipment, max(date),job
from equipment_list
group by equipment, job

doesn't work because the job is always different. I still get multiple lines per piece of equipment.

Thanks in advance,
Carol
 
Something like this ?
SELECT A.equipment, A.date, A.job
FROM equipment_list AS A INNER JOIN (
SELECT equipment, Max([date]) AS MaxDate FROM equipment_list GROUP BY equipment
) AS M ON A.equipment = M.equipment AND A.date = M.MaxDate

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH:
As always, your are the BEST. Thank you for your fast and accurate solution!
Carol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top