FileA
aakey1
aanum1
aanum2
aanum3
aanum4
aanum5
FileB
bbkey1
bbkey2
bbnum1
bbnum2
bbnum3
bbnum4
bbnum5
I need to subtract from FileA fields aanum1-aanum5, the vaules from FileB fields bbnum1-bbnum5, for a specific matching FileB record
The only way I can think of to do this is:
Is there a way to do this without specifying the FileB select statement 6 times?
I can't use MATCH as we are only on v6.1, so MATCH is not supported
aakey1
aanum1
aanum2
aanum3
aanum4
aanum5
FileB
bbkey1
bbkey2
bbnum1
bbnum2
bbnum3
bbnum4
bbnum5
I need to subtract from FileA fields aanum1-aanum5, the vaules from FileB fields bbnum1-bbnum5, for a specific matching FileB record
The only way I can think of to do this is:
Code:
update FileA f1 set aanum1 = aanum1 - (select bbnum1 from FileB f2 where f1.aakey1 = f2.bbkey1 and f2.bbkey2 = something), aanum2 = aanum2 - (select bbnum2 from FileB f2 where f1.aakey1 = f2.bbkey1 and f2.bbkey2 = something), aanum3 = aanum3 - (select bbnum3 from FileB f2 where f1.aakey1 = f2.bbkey1 and f2.bbkey2 = something), aanum4 = aanum4 - (select bbnum4 from FileB f2 where f1.aakey1 = f2.bbkey1 and f2.bbkey2 = something), aanum5 = aanum5 - (select bbnum5 from FileB f2 where f1.aakey1 = f2.bbkey1 and f2.bbkey2 = something) where exists (select 1 from FileB f2 where f1.aakey1 = f2.bbkey1 and f2.bbkey2 = something)
I can't use MATCH as we are only on v6.1, so MATCH is not supported
Comment