title: how can i get sum of last 3 transaction in sql query
body: <p>i have a table name attendents and i want to get sum of last 3 transaction of each mem_id
  i write query to get sum of all transaction for each mem_id.but i didnt know how to get sum of last 3 transaction for each member.</p>
  
  <p>i am using ms accsess database thank you
  my table data is</p>
  
  <pre><code>CREATE TABLE `attendents` (
      `tr_id` INTEGER,
      `mem_id`    NUMERIC,
      `result`    INTEGER,
      PRIMARY KEY(`tr_id`)
  );
  </code></pre>
  
  <p>my current query is</p>
  
  <pre><code>select mem_id,sum(result)
  from attendents
  group by mem_id
  ;
  </code></pre>
  
  <p>my table data is<br>
  tr_id | mem_id | result <br>
  1     &nbsp; &nbsp;&nbsp;   1 &nbsp;&nbsp;&nbsp;      1&nbsp;&nbsp;<br>
  2    &nbsp;&nbsp;    2   &nbsp;&nbsp;    0&nbsp;&nbsp;<br>
  3    &nbsp;&nbsp;    1 &nbsp;&nbsp;      0&nbsp;&nbsp;<br>
  4      &nbsp;&nbsp;  2 &nbsp;&nbsp;      1&nbsp;&nbsp;<br>
  5     &nbsp;&nbsp;   1 &nbsp;&nbsp;      1&nbsp;&nbsp;<br>
  6     &nbsp;&nbsp;   2 &nbsp;&nbsp;      1&nbsp;&nbsp;<br>
  7     &nbsp;&nbsp;   1 &nbsp;&nbsp;      0&nbsp;&nbsp;<br>
  8    &nbsp;&nbsp;    2  &nbsp;&nbsp;     1&nbsp;&nbsp;<br></p>
  
  <p>then last 3 transaction sum should be  mem_id 1= 1  and mem_id 2=3   </p>