melissasiobhan
Technical User
I have a database of empoyees and trainings. Each employee muct be retrained every few years and it must be documented for the State.
I need to query and get the top 2 dates for each employee and training category. Nothing I have tried works. Top 2 only finds the last 2 dates and who took those classes. I know I am not grouping right.
I have a query of each training which in SQL looks like
SELECT tbl_TRAINREG.EMPLKEY, tbl_TRAINREG.EMPLTRAINKEY, tbl_TRAININGS.TRAINDATE, tbl_TRAININGS.TRAINCATKEY, tbl_TRAINREG.TRAINSTATUS
FROM tbl_TRAININGS INNER JOIN tbl_TRAINREG ON tbl_TRAININGS.TRAINKEY = tbl_TRAINREG.TRAINKEY
GROUP BY tbl_TRAINREG.EMPLKEY, tbl_TRAINREG.EMPLTRAINKEY, tbl_TRAININGS.TRAINDATE, tbl_TRAININGS.TRAINCATKEY, tbl_TRAINREG.TRAINSTATUS
HAVING (((tbl_TRAINREG.TRAINSTATUS)="COMPLETED"));
How can I do this in query to only show 2 dates per employee (EMPLKEY) & category (TRAINCATKEY)
I haven't been able to this in query - how about reports? If there is a way to limit the results in my report to only show 2 records per group I could do it that way.
Right now to get the report delivered I made a subreport of the dates for each category and made the detail section only large enough to show 2 rows and changed Can Grow to No. Not the best permenent solution - I know!
I need to query and get the top 2 dates for each employee and training category. Nothing I have tried works. Top 2 only finds the last 2 dates and who took those classes. I know I am not grouping right.
I have a query of each training which in SQL looks like
SELECT tbl_TRAINREG.EMPLKEY, tbl_TRAINREG.EMPLTRAINKEY, tbl_TRAININGS.TRAINDATE, tbl_TRAININGS.TRAINCATKEY, tbl_TRAINREG.TRAINSTATUS
FROM tbl_TRAININGS INNER JOIN tbl_TRAINREG ON tbl_TRAININGS.TRAINKEY = tbl_TRAINREG.TRAINKEY
GROUP BY tbl_TRAINREG.EMPLKEY, tbl_TRAINREG.EMPLTRAINKEY, tbl_TRAININGS.TRAINDATE, tbl_TRAININGS.TRAINCATKEY, tbl_TRAINREG.TRAINSTATUS
HAVING (((tbl_TRAINREG.TRAINSTATUS)="COMPLETED"));
How can I do this in query to only show 2 dates per employee (EMPLKEY) & category (TRAINCATKEY)
I haven't been able to this in query - how about reports? If there is a way to limit the results in my report to only show 2 records per group I could do it that way.
Right now to get the report delivered I made a subreport of the dates for each category and made the detail section only large enough to show 2 rows and changed Can Grow to No. Not the best permenent solution - I know!