title: sql group by only rows which are in sequence
body: <p>Say I have the following table:</p>
  
  <pre><code>MyTable
  ---------
  | 1 | A |
  | 2 | A |
  | 3 | A |
  | 4 | B |
  | 5 | B |
  | 6 | B |
  | 7 | A |
  | 8 | A |
  ---------
  </code></pre>
  
  <p>I need the sql query to output the following:</p>
  
  <pre><code>---------
  | 3 | A |
  | 3 | B |
  | 2 | A |
  ---------
  </code></pre>
  
  <p>Basically I'm doing a <code>group by</code> but only for rows which are together in the sequence. Any ideas?</p>
  
  <p>Note that the database is on sql server 2008. There is a post on this topic however it uses oracle's lag() function. </p>