title: Find Distinct Records over a period of a month
body: <p>I have table called <code>DataFile</code>. This keeps all my data records that get stored in a daily bases.</p>
  
  <p>Data in this table looks like the below:</p>
  
  <pre><code>Id      ConfigAccountId Shelf       FileIdentifier  Created
  5356341 23              BSAS020006  C200094         28/01/2013
  5356342 23              BSAS020006  C200095         28/01/2013
  5356343 23              BSAS020006  C200096         28/01/2013
  5356344 23              BSAS020006  C200097         28/01/2013
  5356345 23              BSAS020006  C200098         28/01/2013
  5356346 23              BSAS020006  C200099         28/01/2013
  5356347 23              BSAS020006  C200100         28/01/2013
  5356348 23              BSAS020006  C200101         28/01/2013
  5356349 23              BSAS020006  C200102         28/02/2013
  5356350 23              BSAS020006  C200103         28/02/2013
  5356351 23              BSAS020006  C200104         28/02/2013
  5356352 23              BSAS020006  C200105         28/02/2013
  5356353 23              BSAS020006  C200106         28/02/2013
  5356354 23              BSAS020006  C200107         28/02/2013
  5356355 23              BSAS020007  C200108         28/02/2013
  5356356 23              BSAS020007  C200109         28/02/2013
  </code></pre>
  
  <p>If you look at the data, the <code>shelf</code> column will change number only when it is full, however I need to know how many unique <code>shelf</code> codes I have for the month. The problem is that <code>shelf</code> <code>BSAS020006</code> runs over two month period so if I run a distinct for <code>February</code> it will count <code>shelf</code> <code>BSAS020006</code> again(I hope I'm making sense). I need a unique <code>Shelf</code> count every month. So if a <code>shelf</code> number has already been reported on in <code>Jan</code>, and it runs over to <code>Feb</code> it must only show the count for <code>Jan</code>.</p>
  
  <p>This is the code I have so far:</p>
  
  <pre><code>select distinct Shelf
  from DataFile
  where Created Between convert(datetime, '2015-10-01 00:00:01', 102) and 
                        convert(Datetime, '2015-10-31 23:59:59', 102)
  </code></pre>
  
  <p>My Output must show, But please note that a shelf can run over to a new month, and therefore must not be shown in that month as well.</p>
  
  <pre><code>Month    Shelf Count
  January       15
  February      16
  March         10
  </code></pre>