title: SQL - Returning the Top two Results for Each Match
body: <p>I have a situation where we record every change to a column of a member record in the <code>MEMBER</code> table as a separate row. The changes that are logged only show the column name that was changed, the new value and the date the change was made.</p>
  <p>Example: Table Name - CustomerChanges</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>customerId</th>
  <th>columnName</th>
  <th>newValue</th>
  <th>dateChanged</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1234</td>
  <td>status</td>
  <td>Active</td>
  <td>1/12/2021</td>
  </tr>
  <tr>
  <td>1234</td>
  <td>status</td>
  <td>Cancelled</td>
  <td>9/30/2020</td>
  </tr>
  <tr>
  <td>1234</td>
  <td>status</td>
  <td>Frozen</td>
  <td>7/1/2020</td>
  </tr>
  <tr>
  <td>1234</td>
  <td>status</td>
  <td>Active</td>
  <td>1/1/2020</td>
  </tr>
  <tr>
  <td>5678</td>
  <td>status</td>
  <td>Active</td>
  <td>1/11/2021</td>
  </tr>
  <tr>
  <td>5678</td>
  <td>status</td>
  <td>Frozen</td>
  <td>11/1/2020</td>
  </tr>
  <tr>
  <td>5678</td>
  <td>status</td>
  <td>Active</td>
  <td>2/1/2020</td>
  </tr>
  <tr>
  <td>9101</td>
  <td>status</td>
  <td>Active</td>
  <td>1/10/2021</td>
  </tr>
  <tr>
  <td>9101</td>
  <td>type</td>
  <td>Full Time</td>
  <td>1/10/2021</td>
  </tr>
  <tr>
  <td>9101</td>
  <td>status</td>
  <td>Frozen</td>
  <td>10/15/2020</td>
  </tr>
  <tr>
  <td>9101</td>
  <td>status</td>
  <td>Active</td>
  <td>1/1/2020</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need to do 3 things here:</p>
  <ol>
  <li>Pull all of the changes for <code>status</code> only</li>
  <li>Grab all of the Customers that went from <code>Frozen</code> to <code>Active</code>. I believe the way to go about it is to pull the top two records for each <code>customerId</code> and  then see who went from <code>Frozen</code> to <code>Active</code>.</li>
  <li>Who did it in the specified time frame...in this example it would be <code>January</code>.</li>
  </ol>
  <p>Considerations:</p>
  <ol>
  <li>As stated earlier, the table has changes for all columns just not the <code>status</code> column.</li>
  <li>The Customer can have many entries of <code>status</code> changes.</li>
  </ol>
  <p>I am working in SSRS and have been struggling with this. I tried to query the table for changes to the column <code>columnName</code>, group it by <code>CustomerId</code>, grab the top two rows and then see which ones went from <code>Frozen</code> to <code>Active</code>.</p>
  <p>Thank you in advance.</p>