I have 2 tables as below and below is my requirement:
1. Find if there are duplicates for any column in any row. For example, row1 in table1 and row1 in Table2 have ‘2’ in common. Pull such records and generate a record combining both and removing duplicate like row1 in Table3(Final output)
2. One condition is when combining such records if total values exceed 20, split into 2 records. Like Row4 in Table1 and Row4 in Table2 together after removing duplicates have 22 values, from Table3 you can see that it is split into 2 rows.
Table1:
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
2 | 3 | | | | | | | | | | | | | | | | | | |
1 | 11 | 56 | 48 | 22 | 38 | | | | | | | | | | | | | | |
81 | 54 | | | | | | | | | | | | | | | | | | |
10 | 9 | 8 | 7 | 6 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 25 | | |
Table2:
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
77 | 2 | 78 | | | | | | | | | | | | | | | | | |
60 | 61 | 62 | 63 | | | | | | | | | | | | | | | | |
88 | 89 | 54 | 86 | 90 | | | | | | | | | | | | | | | |
29 | 30 | 31 | 10 | 9 | 8 | 45 | | | | | | | | | | | | | |
Final Output(Table3):
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
2 | 3 | 77 | 78 | | | | | | | | | | | | | | | | |
1 | 11 | 56 | 48 | 22 | 38 | | | | | | | | | | | | | | |
81 | 54 | 88 | 89 | 86 | 90 | | | | | | | | | | | | | | |
60 | 61 | 62 | 63 | | | | | | | | | | | | | | | | |
10 | 9 | 8 | 7 | 6 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 25 | 29 | 30 |
31 | 45 | | | | | | | | | | | | | | | | | | |
How can I achieve this. Thanks in advance!