Display only most recent results in query

Design by Sue

Registered User.
Local time
Yesterday, 18:21
Joined
Jul 16, 2010
Messages
809
I have a select query that displays a number of fields, including (but not limited to) EmployeeNumber and DateCompleted. The underlying table can have many of these in combination because it is tracking all of the training completed by an Employee but in the report I only want to display the most recent of the trainings for all employees. How do I limit the results to display all employees and only the most recently completed training?

Thanks as always
 
Sorry this is probably more complex that stated. Here is my code for the current query. This displays all records in the database for completed training. In this example the results are for one employee and for all of the training they have completed. I need to limit each the results to the most recent of every one of the trainings (SOP Number) completed.



SELECT [Main TBL].[Employee Number], [Main TBL].DateCompleted, [Main TBL].[SOP Number], Format([Main TBL]![SOPVersion],"""-v""00") AS SOPVersion, [SOP TBL].Description, [SOP TBL].Type, [Employee TBL].[Last Name], [Employee TBL].[First Name], [SOP TBL].Expiration, [Employee TBL].Inactive, SOPVersionTBL.Obsolete
FROM ([SOP TBL] INNER JOIN ([Employee TBL] INNER JOIN [Main TBL] ON [Employee TBL].[Employee Number] = [Main TBL].[Employee Number]) ON [SOP TBL].[SOP Number] = [Main TBL].[SOP Number]) INNER JOIN SOPVersionTBL ON (SOPVersionTBL.SOPVersion = [Main TBL].SOPVersion) AND ([Main TBL].[SOP Number] = SOPVersionTBL.[SOP Number]) AND ([SOP TBL].[SOP Number] = SOPVersionTBL.[SOP Number])
WHERE ((([Main TBL].[Employee Number])=[Forms]![Employee Name Parameter FRM]![LastName]) AND (([Employee TBL].Inactive)=False) AND ((SOPVersionTBL.Obsolete)=False));
 
Take a look at Allen Browne's page on subqueries, maybe it will help.
 

Users who are viewing this thread

Back
Top Bottom