Hi,
I have a source table below:
organization interco account curr amount organization interco account curr amount
3050000 2650000 2331200D USD 315.00 2650000 3050000 4132000D USD -15.00
3050000 3051000 2331200D USD -58421.43 3051000 3050000 4132000D USD -1115.16
3050000 3051000 2331200D USD -58421.43 3051000 3050000 4163100D USD -352000.00
3050000 3051000 2331200D USD -58421.43 3051000 3050000 4163200D USD -10.31
Below is my interco_flag table. It determines which account to match by the flag values to filter the records in source table.
account flag
2331100D 1
2331200D 2
4131000D 1
4132000D 2
Since the flag = 2 matches the account ID in the source table, the desired results will look like this:
organization interco account curr amount organization interco account curr amount
3050000 2650000 2331200D USD 315.00 2650000 3050000 4132000D USD -15.00
3050000 3051000 2331200D USD -58421.43 3051000 3050000 4132000D USD -1115.16
How can I construct the sql in order to match the account ID flag in the source table?