Let's say I have few tables of the following format:
| Status | Date_2, Date_1 |
| ------------ | ------------ |
| Alive | 15 |
| Dead | -4 |
| Unknown | 25 |
Status | Date_3, Date_2 |
---|---|
Alive | 56 |
Dead | 44 |
Unknown | -244 |
Status | Date_4, Date_3 |
------------ | ------------ |
Alive | 18 |
Dead | 2 |
Unknown | 5 |
And so on.
The final result should look like:
| Status | Date_2, Date_1 | Date_3, Date_2 | Date_4, Date_3 |
| ------------ | ------------ | ------------ | ------------ |
| Alive | 15 | 56 | 18 |
| Dead | -4 | 44 | 2 |
| Unknown | 25 | -244 | 5 |
How would I set up a Temp Table so that I could append the above data to it a loop so that they appear next to each other? The issue is that I already have @DynamicSQL which produces the above tables. All I want now is for them to be concatenated next to each other so that I don't have to copy them one by one into Excel to produce the necessary graphs.
2条答案
按热度按时间vdgimpew1#
Here is the possible solution. Instead of trying to join the table next to each other, just add them on top of each other. But, to distinguish to which time period of each subsequent addition belongs to, add the new column in the table which shows the time period. Then just use the pivot table in Excel to get the data in the desired format. Will post code late.r
ttcibm8c2#
Try this one,