By means of this, I was able to analyze that serial used in SO is different/same as used in DR.
To match so entries with dr entries you can join table b twice, first time take ‘so’ entries then second time take ‘dr’ entries. So you will get “header”, “SoEntry”, “DrEntry”. Then you can compare them. Take this example
select t1.BP, t1.ITEMCODE, t21.Serial as SO_SERIAL, t22.SERIAL as DR_Serial
FROM table1 t1
LEFT JOIN table2 t21 on t21.ITEMCODE=t1.ITEMCODE and t21.BASETYPE=17
LEFT JOIN table2 t22 on t22.ITEMCODE=t1.ITEMCODE and t22.BASETYPE=15
2
solved Joining multiple tables in one