title: How can I get up to the last 2 details for each master record?
body: <p>I need a query in MS-Access that will return up to the last to classes each student has completed. the data looks something like this:</p>
  
  <p>Students </p>
  
  <pre><code> ID  | StudentName
   1     John
   2     Bill
   3     Ted
   4     Edward
  </code></pre>
  
  <p>TrainingDetails</p>
  
  <pre><code>   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 
  </code></pre>
  
  <p>Desired Output</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I've tried using the <code>SELECT TOP 2</code> clause, but i only get 2 records total. I think i need some type of loop to get each student and then the top 2 records for each student, but I can't get it all in a single query.</p>