Sorry . that was only half of the work I had to do. tuens out that every time I have negative value in col3 I have to turn col3 positive and flip col1 and col2 values and then group so if have:
col1 col2 col3
A B 100
B A -50
A C 200
A D 100
A B 150
B F 200
C D -50
I have to produce
col1 col2 col3
A B 300
A C 200
A D 100
B F 200
D C 50