title: MS Access: select first occurrence within a group
body: <p>I have some data on individuals in our database. I need to select each observation only once, but that selection needs to be of the earliest occurrence. </p>
  
  <p>There are 2 identifiers for occurrence though, year, and quarter:</p>
  
  <pre><code> CustID     | OrderYear | Quarter 
   0001       |  2012     |   3
   0001       |  2012     |   4
   0001       |  2013     |   1
   0002       |  2012     |   3
   0002       |  2012     |   4
   0003       |  2013     |   1
  </code></pre>
  
  <p>I need the select statement to grab it so that the output is:</p>
  
  <pre><code> CustID     | OrderYear | Quarter 
   0001       |  2012     |   3
   0002       |  2012     |   3
   0003       |  2013     |   1
  </code></pre>
  
  <p>So, observations are grouped by customer ID, then by Order Year, then by Quarter. Does this make sense? Without quarter I can get it just fine, but I need quarter in order to go the next step of the analysis and when I do that my technique fails. </p>
  
  <p>Without quarter, I could just use <code>First(orderYear)</code> in the select statement, group by <code>CustID</code>, and it works just fine (the dataset is sorted by CustID and then Year, and then Quarter in ascending order, so in this case the First() grabs the earliest occurrence</p>
  
  <pre><code>SELECT CustID, First(OrderYear)
  FROM Table1
  GROUP BY CustID
  </code></pre>
  
  <p>The added layer of quarter is throwing me off though.</p>
  
  <p>Thanks for your help!</p>