title: Limit average to the most recent records
body: <p>I'd like to limit this query to only calculate the average "duration" of the <strong>last 10</strong> "question" answered by a "student".</p>
  
  <pre><code>SELECT question, AVG(duration) AS timeTaken 
  FROM t_answer 
  WHERE student=2 
  GROUP BY question 
  </code></pre>
  
  <p>i.e. For a given student, fetch a list of questions answered and the average time it has taken them on their <strong>last 10 attempts</strong> of that question...</p>
  
  <pre><code>+----------+-----------+
  | question | timeTaken |
  +----------+-----------+
  | 2        | 3956      |
  +----------+-----------+
  | 5        | 11102     |
  +----------+-----------+
  | 9        | 14527     |
  +----------+-----------+
  </code></pre>
  
  <p>Sample table data...</p>
  
  <pre><code>+---------+----------+----------+---------------------+
  | student | question | duration | when                |
  +---------+----------+----------+---------------------+
  | 1       | 1        | 5301     | 2017-03-10 16:35:11 |
  +---------+----------+----------+---------------------+
  | 2       | 2        | 5217     | 2017-03-10 16:36:51 |
  +---------+----------+----------+---------------------+
  | 1       | 2        | 3459     | 2017-03-10 16:44:42 |
  +---------+----------+----------+---------------------+
  | 2       | 2        | 2694     | 2017-03-10 16:44:55 |
  +---------+----------+----------+---------------------+
  | 2       | 5        | 11102    | 2017-03-10 16:45:10 |
  +---------+----------+----------+---------------------+
  | 2       | 9        | 14527    | 2017-03-10 16:45:14 |
  +---------+----------+----------+---------------------+
  | 3       | 5        | 1763     | 2017-03-10 16:45:47 |
  +---------+----------+----------+---------------------+
  </code></pre>