title: Find first rows of change in historical table
body: <p>I have an old legacy table in MS SQL Server 2008 which needs to be cleaned. Table contains daily rows for multiple products and their daily change parameter. The procedure filling the table is not optimized and is making duplicate rows for each day where only the change should be noted.</p>
  
  <p>Now I already fixed the daily procedure to insert only changed values but now I need to clean the original table.</p>
  
  <p>My plan was to make an extract of only the relevant rows (where change was made MIN(C) Group By B) and insert them into a new table and use this new table. I tried with RANK() but no success, Group By didn't work as the change parameter repeats over time.</p>
  
  <p>This is how it looks like (column A has multiple values, 123, 345, 567 etc. so it need to be in a group also):</p>
  
  <p>a test fiddle <a href="http://sqlfiddle.com/#!3/0da5a/3" rel="nofollow">http://sqlfiddle.com/#!3/0da5a/3</a></p>
  
  <pre><code>A    B    C
  123  0    20130101
  123  0    20130102
  123  1    20130103
  123  1    20130104
  123  0    20130105
  123  2    20130106
  123  2    20130107
  123  2    20130108
  123  0    20130109
  123  3    20130110
  123  3    20130111
  123  3    20130112
  </code></pre>
  
  <p>Expected result is:</p>
  
  <pre><code>123 0 20130101
  123 1 20130103
  123 0 20130105
  123 2 20130106
  123 0 20130109
  123 3 20130110
  </code></pre>
  
  <p>(edit: added column A to expected result)</p>