我需要MS-Access中的一个查询,它将返回到每个学生完成的课程的最后一个。数据看起来是这样的:如何获得每个主记录的最后2个细节?
学生
ID | StudentName
1 John
2 Bill
3 Ted
4 Edward
TrainingDetails
ID | StudentID | ClassName | Date
1 1 Math 10/10/2012
2 1 Science 12/10/2012
3 2 Math 10/10/2012
4 3 Math 10/10/2012
5 2 Art 09/10/2012
6 2 History 02/10/2012
7 3 Science 12/10/2012
8 3 History 02/10/2012
9 4 Music 12/10/2012
所需的输出
Name | Class | Date
John Science 12/10/2012
John Math 10/10/2012
Bill Math 10/10/2012
Bill Art 09/10/2012
Ted Science 12/10/2012
Ted Math 10/10/2012
Edward Music 12/10/2012
我使用SELECT TOP 2
条款试过,但我只得到2记录总数。我想我需要一些循环来获得每个学生,然后每个学生的前2条记录,但我不能在一个查询中得到它。