2011-06-10 100 views
4

我有一個查詢我正在設計哪個抓取多個不同表中的數據。在MS Access 2010中,我將如何創建查詢欄目之一,所以它返回最近日期了一系列日期的,爲表中的每個用戶:從表MS Access查詢 - 選擇最近的日期

的樣本數據:

userid: | appointment: 
000001 | 05/10/2009 
000001 | 05/10/2010 
000001 | 05/11/2010 
000002 | 05/12/2009 
000002 | 30/12/2010

預期輸出現場查詢:

userid: | appointment: 
000001 | 05/11/2010 
000002 | 30/12/2010

回答

4
SELECT userid, Max(appointment) AS most_recent 
FROM YourTable 
GROUP BY userid; 
+0

感謝您的幫助 – Sapvinder 2011-06-10 16:06:00

0

SELECT B.Job_Emp_ID,B.JobTitle,B.Salary,B.AssignmentDate FROM tbl_Emp_Job_Assignment as B INNER JOIN tbl_Emp_Job_Assignment as A ON(B.Job_Emp_ID = A.Job_Emp_ID and B.AssignmentDate> A.AssignmentDate) GROUP BY B.Job_Emp_ID,B.JobTitle,B.Salary,B.AssignmentDate;

This Works Great!It gives the job job assignment and Assignment Date。