title: Count of rows of based on a certain condition
body: <p>I have a table which is sorted by <code>sessionid</code> and <code>timestamp</code> <code>ts</code>.  </p>
  
  <p>What I want to find is, the count of <code>sessionids</code> which have atleast one listpage view <code>screen_name = 'listpage'</code> after a cart page page view <code>screen_name = 'checkout_cart'</code> in the same session <code>sessionid</code>.</p>
  
  <p>Table:</p>
  
  <pre><code>sessionid screen_name ts
  
  11 checkout_cart 1593
  11 checkout_cart 1594
  12 checkout_cart 1890
  12 home_page 1892
  12 list_page 1894
  12 checkout_cart 1896
  13 list_page 1900
  13 checkout_cart 1902
  13 home_page 1904
  14 checkout_cart 1990
  14 home_page 1992
  14 list_page 1994
  14 checkout_cart 1996
  </code></pre>
  
  <p><em>Based on the table my count should be 2 <code>session id 12 and 14,13</code> cant be counted because <code>list_Page</code> is before <code>cart_page</code>
  Please help me in writing a query for this, I am stuck with the logic.</em></p>