Hi everyone!
I have a problem and I can't figure out how to solve it, so I would appreciate any help.
1. I need to check each row in OLD TABLE, look into HELP TABLE for NEW_ID (if exists) and create new ID in NEW TABLE
2. Then I need sum all values that belong to NEW_ID and insert into NEW TABLE with NEW_ID
HELP TABLE
<tbody>
</tbody>
OLD TABLE
<tbody>
</tbody>
NEW TABLE
<tbody>
</tbody>
I have a problem and I can't figure out how to solve it, so I would appreciate any help.
1. I need to check each row in OLD TABLE, look into HELP TABLE for NEW_ID (if exists) and create new ID in NEW TABLE
2. Then I need sum all values that belong to NEW_ID and insert into NEW TABLE with NEW_ID
HELP TABLE
NEW_ID | OLD_ID_1 | OLD_ID_2 | OLD_ID_3 | OLD_ID_4 |
1 | 11 | 22 | 33 | |
2 | 66 | 66 | 88 | |
3 | 77 | 77 | ||
4 | 44 | 55 | 88 | 99 |
<tbody>
</tbody>
OLD TABLE
ID | VALUE |
11 | 1 |
66 | 3 |
22 | 7 |
88 | 9 |
33 | 5 |
77 | 2 |
99 | 4 |
55 | 6 |
44 | 4 |
88 | 7 |
<tbody>
</tbody>
NEW TABLE
ID | VALUE |
1 | 10 |
2 | 12 |
3 | 13 |
4 | 2 |
<tbody>
</tbody>