title: How to get count of consecutive dates
body: <p>For example there is some table with dates:</p>
  
  <pre><code>2015-01-01
  2015-01-02
  2015-01-03
  2015-01-06
  2015-01-07
  2015-01-11
  </code></pre>
  
  <p>I have to write ms sql query, which will return count of consecutive dates starting from every date in the table. So the result will be like:</p>
  
  <pre><code>2015-01-01   1
  2015-01-02   2
  2015-01-03   3
  2015-01-06   1
  2015-01-07   2
  2015-01-11   1
  </code></pre>
  
  <p>It seems to me that I should use LAG and LEAD functions, but now I even can not imagine the way of thinking. </p>