title: Select Statement Complicated data transformation
body: <p>Ok I have 2 tables.</p>
  
  <p>Table A is has a list of transactions for a given client, looks like this</p>
  
  <pre><code>ClientID Transaction  Start      Stop
  1          1          2014-01-01 2014-01-25
  </code></pre>
  
  <p>Table B is a list of events, looks like this:</p>
  
  <pre><code>ClientID Event StartE      StopE
  1         1    2014-01-05 2014-01-08
  1         2    2014-01-10 2014-01-12
  1         3    2014-01-14 2014-01-16
  </code></pre>
  
  <p>I want to "join" these tables together to get the following table:</p>
  
  <pre><code>ClientID Transaction  EFF         ENDS
  1          1          2014-01-01  2014-01-05
  1          1          2014-01-05  2014-01-08
  1          1          2014-01-08  2014-01-10
  1          1          2014-01-10  2014-01-12
  1          1          2014-01-12  2014-01-14
  1          1          2014-01-14  2014-01-16
  1          1          2014-01-16  2014-01-25
  </code></pre>
  
  <p>I have come up with some solutions but it fails in some cases this is example where my code fails. I would like to try and approach this fresh.</p>