title: SQL Ranking by when a column changes
body: <p>I'm working on a problem in SQL where I'm trying to rank a column based on when it changes.</p>
  
  <p>Basically the current table looks like this: </p>
  
  <pre><code>DATE        STATUS
  10/18/10    A        
  10/16/10    A        
  10/14/10    B        
  10/12/10    A        
  </code></pre>
  
  <p>I want to appropriately rank the status column, based on the date column, but only when the status column changes. For example:</p>
  
  <pre><code> DATE        STATUS   RANK 
   10/18/10    A        1 
   10/16/10    A        1 
   10/14/10    B        2 
   10/12/10    A        3 
   10/10/10    A        3
  </code></pre>
  
  <p>Any ideas on how to go about this? I've played around with both RANK() and DENSE_RANK() and am having trouble getting the output I want. Thanks.</p>