I have a database where the vacation and sick for each employee is entered. I would like to get the most recent date for each employee when they received a vacation pay and the most recent date when they received their sick pay.
With the query below I get all the dates that they received vacation and sick pay. I grouped by employee id and by pay type. and tried using last or max but that gives me the latest date for both sick and pay. How can I get the most recent date for vacation and the most recent pay for vacation.
This is my SQL Statement:
Thanks in advance for all your help;
With the query below I get all the dates that they received vacation and sick pay. I grouped by employee id and by pay type. and tried using last or max but that gives me the latest date for both sick and pay. How can I get the most recent date for vacation and the most recent pay for vacation.
This is my SQL Statement:
Code:
SELECT DISTINCTROW tblPRItemHist.EmployeeID, tblPRItemPayHist.PayTypeID, tblPRPayType.PayDescription, tblPRItemHist.CheckDate
FROM tblPRItemHist INNER JOIN (tblPRPayType INNER JOIN tblPRItemPayHist ON tblPRPayType.PayTypeID = tblPRItemPayHist.PayTypeID) ON tblPRItemHist.ItemID = tblPRItemPayHist.ItemID
WHERE (((tblPRItemHist.Voided)=No) AND ((tblPRPayType.ShortName)="Vacation" Or (tblPRPayType.ShortName)="Sick Pay"))
GROUP BY tblPRItemHist.EmployeeID, tblPRItemPayHist.PayTypeID, tblPRPayType.PayDescription, tblPRItemHist.CheckDate
ORDER BY tblPRItemHist.EmployeeID, tblPRItemHist.CheckDate DESC;
Thanks in advance for all your help;