Bigfella928
New member
- Local time
- Today, 15:00
- Joined
- Nov 7, 2020
- Messages
- 4
Hi, All.
Could use some help here please. Complete novice at SQL or Access for that matter
I have a table of records that stores training card information including date date added, expiry date, employee name, card type, Card Serial No.
Each employee could have multiple cards of the same type over time and the serial No. tends to be the same.
I want to create a report of expired cards which is easy.
However, I want to ignore an expired card if a new card has been obtained.
I have tried a max query which, on the data I have, reports back all of the cards which match the card type criteria but do not get the last card for that employee.
In one case this means three entries on one employee.
The question therefore is how do I now select the latest of these records please, such that I end up with the latest card of a given type.
Below is the SQL I have at the moment
SELECT Tbl_EmpCards.Employee_Name, Max(Tbl_EmpCards.Date_Added) AS [Max], Tbl_EmpCards.CSCS_YN, Tbl_EmpCards.Card_Name, Tbl_EmpCards.Card_GenName, Tbl_EmpCards.Card_No, Tbl_EmpCards.Card_Duration, Tbl_EmpCards.Card_Expiry
FROM Tbl_EmpCards
GROUP BY Tbl_EmpCards.Employee_Name, Tbl_EmpCards.CSCS_YN, Tbl_EmpCards.Card_Name, Tbl_EmpCards.Card_GenName, Tbl_EmpCards.Card_No, Tbl_EmpCards.Card_Duration, Tbl_EmpCards.Card_Expiry
HAVING (((Tbl_EmpCards.Card_Name) Not Like "*HS&E*"));
Thanks in advance for any assistance please.
Could use some help here please. Complete novice at SQL or Access for that matter
I have a table of records that stores training card information including date date added, expiry date, employee name, card type, Card Serial No.
Each employee could have multiple cards of the same type over time and the serial No. tends to be the same.
I want to create a report of expired cards which is easy.
However, I want to ignore an expired card if a new card has been obtained.
I have tried a max query which, on the data I have, reports back all of the cards which match the card type criteria but do not get the last card for that employee.
In one case this means three entries on one employee.
The question therefore is how do I now select the latest of these records please, such that I end up with the latest card of a given type.
Below is the SQL I have at the moment
SELECT Tbl_EmpCards.Employee_Name, Max(Tbl_EmpCards.Date_Added) AS [Max], Tbl_EmpCards.CSCS_YN, Tbl_EmpCards.Card_Name, Tbl_EmpCards.Card_GenName, Tbl_EmpCards.Card_No, Tbl_EmpCards.Card_Duration, Tbl_EmpCards.Card_Expiry
FROM Tbl_EmpCards
GROUP BY Tbl_EmpCards.Employee_Name, Tbl_EmpCards.CSCS_YN, Tbl_EmpCards.Card_Name, Tbl_EmpCards.Card_GenName, Tbl_EmpCards.Card_No, Tbl_EmpCards.Card_Duration, Tbl_EmpCards.Card_Expiry
HAVING (((Tbl_EmpCards.Card_Name) Not Like "*HS&E*"));
Thanks in advance for any assistance please.