I'm wondering if there is an obvious way of joining two tables that I'm overlooking.
If data is loaded into a table so that only the deltas are logged how does one go about joining different tables together? There is no obvious join between the tables because the dates aren't guaranteed to match 1:1 on dates/keys
Given the following simple structure:
BeginDate | EndDate | Id | Col1 | Col2 ...
Table A might contain the data:
1/1/2014 | 1/7/2014 | 1 | A | i
1/7/2014 | 1/15/2014 | 1 | B | i
Table B might contain the data:
1/1/2014 | 1/3/2014 | 1 | ABCDEF | 123
1/3/2014 | 1/8/2014 | 1 | FEDCBA | 321
1/8/2014 | 1/15/2014 | 1 | QWERTY | 314
How would you go about joining these two tables equally? My current approach has been to APPLY all of the tables against a calendar first to generate entries for each date and then to join those results on Date/Key but this is obviously quite inefficient.
Example desired output:
1/1/2014 | 1/3/2014 | 1 | A | i | ABCDEF | 123
1/3/2014 | 1/7/2014 | 1 | A | i | FEDCBA | 321
1/7/2014 | 1/8/2014 | 1 | B | i | FEDCBA | 321
1/8/2014 | 1/15/2014 | 1 | B | i | QWERTY | 314