I have two tables, one is an older version old_unitvalue of the other one. The newest table new_unitvalue needs to be populated with the data contained in the old version the problem is that the structure of the table has changed.
old_unitvalue:
| UNIT | LOC | PERIOD | VALUE |
|--------|------|--------|-------------|
| 1001 | 99 | 1 | 0.712234544 |
| 1001 | 99 | 2 | 3 |
| 1001 | 99 | 3 | 2.333333333 |
| 1001 | 99 | 4 | 3 |
new_unitvalue:
| UNIT | LOC | PERIOD1 | PERIOD2 | PERIOD3 | PERIOD4 |
| -------- | -------------- | ------------ | ------------ | ------------ | ------------ |
| 1001 | 99 | 0.712234544 | 3 | 2.333333333 | 3 |
Note that these are just referral tables, in the originals periods goes up to 52.
Previous new_unitvalue example is how the final result should be, my questions is if there is a way to update those without the need to generate a temp table to transition the data. I'm very new to SQL so I have not yet figured it out how to do so.