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

Need most recent date

Status
Not open for further replies.

ccjjscb

Technical User
Jan 18, 2006
29
US
I have a query that I need to have the most recent training dates brought into, not sure where to go from here, any suggestions? Here is the SQL view of the query.
Thanks for any help/suggestions.
Chris

SELECT tblEmployees.[Employee Number], tblEmployees.[Employee Full Name], tblCourses.[Course Name], tblTrainingDates.[Training Date]
FROM tblEmployees INNER JOIN (tblCourses INNER JOIN tblTrainingDates ON tblCourses.[Course ID] =tblTrainingDates.[Course ID]) ON tblEmployees.[Employee Number] = tblTrainingDates.[Employee Number]
WHERE (((tblCourses.[Current Course])=Yes) AND ((tblEmployees.[Active Employee?])=Yes))
ORDER BY tblEmployees.[Employee Last Name], tblCourses.[Course Name], tblTrainingDates.[Training Date];
 
Not sure but is it parameter boxes with "between dates" that your looking for or "greater than a certain date". I think you will need to supply more information for someone to be able to help.
 
I assume that you want the MAX date instead of just the one on each record.
Code:
SELECT E.[Employee Number], E.[Employee Full Name], C.[Course Name], 
       MAX(D.[Training Date]) As [Latest Date]

FROM tblEmployees E 
     INNER JOIN (tblCourses C 
                 INNER JOIN tblTrainingDates D 
                ON C.[Course ID] =D.[Course ID]) 
     ON E.[Employee Number] = D.[Employee Number]

WHERE C.[Current Course]=Yes 
  AND E.[Active Employee?]=Yes

GROUP BY E.[Employee Number], E.[Employee Full Name], C.[Course Name]

ORDER BY E.[Employee Last Name], C.[Course Name], D.[Training Date];

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
What I am after is the most recent date for each employee for each course, it would be stored in tblTrainingDates.[Training Date]. Each employee may have several training dates for each course, only the most recent one is what I want in the query. Please let me know if you need more info.
Thanks
Chris
 
That's what I did. Have you tried it?

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Golom, I tried what you suggested and it does work. I was writing my reply to the one from lars7 at the same time you were posting so I didn't see your post until I posted mine.
Thanks for the help
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top