title: Count for consecutive records
body: <p>I have a table as follows</p>
  
  <blockquote>
  <pre><code>&gt; RowID   SessionID       EventID  RequestedURL   Date
  &gt; 1       m2jqyc45g       1        Start          24/03/2010 19:52
  &gt; 2       m2jqyc45g       1        ProductPage    24/03/2010 19:52
  &gt; 3       m2jqyc45g       28       BuyNow         24/03/2010 19:52
  &gt; 4       tjmvb55dc4dg    1        ProductPage    24/03/2010 19:52
  &gt; 5       tjmvb55dc4dg    1        BuyNow         24/03/2010 19:56
  &gt; 6       tjmvb55dc4dg    1        Clicked OK     24/03/2010 19:56
  &gt; 7       m2jqyc45g       1        Clicked OK     24/03/2010 19:56
  &gt; 8       tjmvb55dc4dg    28       Help           24/03/2010 19:56
  &gt; 9       m2jqyc45g       1        Home           24/03/2010 19:56
  &gt; 6       m2jqyc45g       1        ProductPage    24/03/2010 19:56
  &gt; 7       tjmvb55dc4dg    1        BuyNow         24/03/2010 19:56
  &gt; 8       tjmvb55dc4dg    28       Clicked OK     24/03/2010 19:56
  &gt; 9       tjmvb55dc4dg    1        Home           24/03/2010 19:56
  </code></pre>
  </blockquote>
  
  <p>How do I write a query that does a count whenever the rows BuyNow and Clicked OK have been recorded consecutively in a particular session? 
  For example, the dataset above shows 2 users on the site recording separate sessions. The return count should be 3.</p>
  
  <p>I'm running SQL Server 2008</p>
  
  <p><strong>EDIT</strong>
  Just to clarify What I mean by consecutive rows and why the count should return 3. In the session m2jqyc45g, the BuyNow and Clicked Ok occurs consecutive within the session but when it's entered into the table, there are other concurrent sessions too which breaks the sequence. If you were to order the result set by SessionID and then by Date, you will get them one after the other. Also, there was a typo with RowID7, ProductPage should be BuyNow. Sorry for that.</p>