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

Help Developing SQL Query

Status
Not open for further replies.

byrne1

Programmer
Joined
Aug 7, 2001
Messages
415
Location
US
I need to create a query that will pull all of the records that are statused as 'OUT' from my RECORDS table and then get the last (chronologically) 'OUT' record from my IN/OUT table for each record it pulled from RECORDS.

I can get the records out of RECORDS without any problems but I don't know how to set up a query that will pull the last chronological 'OUT' record from my IN/OUT table. Is there a way to do this in SQL?

Thank you in advance for any help.
 
Without specific information - column names, data types, relationships - the best I can do is provide a general answer.
[tt]
Select a.*, b.OutDate
From Records As a
Inner Join (Select ID, Max(OutDate) As OutDate
From InOut Group By ID) As b
On a.ID=b.ID
Where a.Status = 'OUT'[/tt] Terry

Neither success nor failure is ever final. -Roger Babson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top