Description
- I have a file which includes original data and updated statements.
- The row original_id is like a primary key.
- Rows which have no value in change_request_id are initial data entries.
- Rows which have values in change_request_id are updates to the initial data entries.
- The row change_request_id references the row original_id and represents a data change(update). Only values which need to be changed are represented as value, if the field is empty it means the value does not change.
Original File
change_request_id | original_id | a | b | c | d |
---|---|---|---|---|---|
1 | 10 | 20 | 30 | 40 | |
2 | 2500 | 600 | 700 | 800 | |
1 | 3 | 12 | |||
2 | 4 | 700 | 800 | ||
1 | 5 | 30 | |||
6 | 16 | 17 | 19 | 20 |
Desired Output:
change_request_id | original_id | a | b | c | d |
---|---|---|---|---|---|
1 | 12 | 30 | 30 | 40 | |
2 | 500 | 700 | 800 | 800 | |
6 | 16 | 17 | 19 | 20 |