Ok I have 2 tables.
Table A is has a list of transactions for a given client, looks like this
ClientID Transaction Start Stop
1 1 2014-01-01 2014-01-25
Table B is a list of events, looks like this:
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
I want to "join" these tables together to get the following table:
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
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.