title: Join query on Date Range
body: <p>HI<br>
  I have following tables</p>
  
  <pre><code>=========================
  Periods
  =========================
  PeriodID  StartDate   EndDate
  1         01-01-11    07-01-11
  2         08-01-11    15-01-11
  </code></pre>
  
  <p>and so on for whole year</p>
  
  <pre><code>=========================
  History
  =========================
  PersonID  From       To
  1         01-01-11  05-04-11
  2         17-06-11   NULL 
  and so on
  </code></pre>
  
  <p>I want the following output</p>
  
  <pre><code> StartDate   EndDate   PersonID
    01-01-11    07-01-11    1
    08-01-11    15-01-11    1
    .
    .
    15-04-11   21-04-11     NULL
    .
    .
    15-06-11   21-06-11     2
  </code></pre>
  
  <p>I need to take  join between these two tables but i couldn't figure how join condition will be look like </p>
  
  <p>Ragards</p>