Hi,
For me algorithm from
is the simplest and the fastest if you are saying that source table is huge:- It iterates once through source loop and updates values in place - just read row and update col2 if needed.
- We need to read all rows at least once to check if col2 from row must be left or it should be cleared. This algorithm reads each row only once.
- It uses assigning so in case of large table is important for performance - data is directly updated.
- It does not need any additional tables/structures, only single l_col2 variable as temporal one.
There is no need to sort also by col2, col1 sorted order is enough.
If values of col2 can be duplicated for different col1 values, like:
col1 = 22 col2 = ABC
col1 = 22 col2 = ABC
col1 = 23 col2 = ABC
... then in the loop if condition must refer to col1 instead of col2:
IF l_col1 = <it>-col1. ...
Regards,
Adam