I use the following query today
COALESCE(SUM(FROM_QTY), (SUM(TO_QTY)*-1))as FROM_QTY,
COALESCE(SUM(TO_QTY), (SUM(FROM_QTY)*-1)) as TO_QTY
GROUP BY REF, DATE, LEV1, LEV2
Before the Group BY, each row will contain a FROM_CODE or a TO_CODE, but rarely both.
After the Group By each summarized record will always have both a FROM_CODE and TO_CODE
What I want to do, is exlcude any rows where the value is the same in both columns. If we need to specify them there are only 4 values (UNR, QI, BLK, DIS or XX). Can anyone help me do this?