title: Count number of days in a year with a record
body: <p>I have a SQL Server table named <strong>AgentLog</strong> in which I store for each agent his daily number of sales.</p>
  
  <pre><code>+-----------+------------+-------------+
  | AgentName |    Date    | SalesNumber |
  +-----------+------------+-------------+
  | John      | 01.01.2014 |          45 |
  | Terry     | 01.01.2014 |          30 |
  | John      | 02.01.2014 |          20 |
  | Terry     | 02.01.2014 |          15 |
  | Terry     | 03.01.2014 |          52 |
  | Terry     | 04.01.2014 |          24 |
  | Terry     | 05.01.2014 |          12 |
  | Terry     | 06.01.2014 |          10 |
  | Terry     | 07.01.2014 |          23 |
  | John      | 08.01.2014 |          48 |
  | Terry     | 08.01.2014 |          35 |
  | John      | 09.01.2014 |          37 |
  | Terry     | 10.01.2014 |          35 |
  +-----------+------------+-------------+
  </code></pre>
  
  <p>If an agent doesn't work on one particular day, there is no record of his sales on that date.</p>
  
  <p>I want to generate a report(query) on a given date interval (ex: 01.01.2014 - 10.01.2014) that counts on how many days an agent wasn't present for work (ex: John - 6 days), was at work (John - 4 days) and also returns the date interval it wasn't present (ex: John 03.01.2014 - 07.01.2014, 10.01.2014) (there can be multiple intervals).</p>