S
sunrise987
Hi,
I have a table that keeps track of every change of marital status for
all employees. The table consists of these fields:
EntryNumber, EmployeeID, Status, DateOfUpdate
The information that I am trying to extract from this table is : the
latest "DateOfUpdate" and its corresponding "Status" for each
"EmployeeID".
My strategy for getting this information is:
1. Sort the table by "DateOfUpdate",
2. Group by the "EmployeeID",
3. Then, for each group get the last record.
Here is the query that I used to the above:
SELECT Temp.EmployeeID, Last(Temp.status) AS LastOfstatus, Last(Temp.
[Date of update]) AS [MaxOfDate of update]
FROM (SELECT * FROM [H_Marital Status] ORDER BY [H_Marital Status].
[Date of update]) AS Temp
GROUP BY Temp.EmployeeID;
But the problem is that Access resorts the table by EmployeeID before
doing the aggregation. So the strategy is not working here. I don't
know any other way to doing this. Any help on this matter is greatly
appreciated.
Faiza
I have a table that keeps track of every change of marital status for
all employees. The table consists of these fields:
EntryNumber, EmployeeID, Status, DateOfUpdate
The information that I am trying to extract from this table is : the
latest "DateOfUpdate" and its corresponding "Status" for each
"EmployeeID".
My strategy for getting this information is:
1. Sort the table by "DateOfUpdate",
2. Group by the "EmployeeID",
3. Then, for each group get the last record.
Here is the query that I used to the above:
SELECT Temp.EmployeeID, Last(Temp.status) AS LastOfstatus, Last(Temp.
[Date of update]) AS [MaxOfDate of update]
FROM (SELECT * FROM [H_Marital Status] ORDER BY [H_Marital Status].
[Date of update]) AS Temp
GROUP BY Temp.EmployeeID;
But the problem is that Access resorts the table by EmployeeID before
doing the aggregation. So the strategy is not working here. I don't
know any other way to doing this. Any help on this matter is greatly
appreciated.
Faiza