Q: Display only rows that do not match the control table I'm currently having a problem since I can't really explain it in words it's better if I put a test table here.
Table1:
Source_DB   Source_TBL   Source_Col   Target_DB   Target_TBL   Target_Col   Metric   Source_VAL   Target_Val
____________________________________________________________________________________________________________
Source_D    Source_T     Col1         Target_D    Target_T     Col1         Index    1            1
Source_D    Source_T     Col1         Target_D    Target_T     Col1         Length   10           10
Source_D    Source_T     Col1         Target_D    Target_T     Col1         Scale    4            4

Control Table:
DB_NM      TBL_NM    COL_NM    METRIC    INCLUDE_FLAG
_____________________________________________________
Source_D   Source_T  Col1      Length    N

Now in the control table, since the include flag is N it should not include the row that matches with the DB_NM, TBL_NM, COL_NM in Table1. I tried using NOT IN(subquery) however I failed since I am comparing many columns. EXISTS is also not allowed because the columns in the control table do not match the columns in Table1. Is there any workaround in this one?
The result should be:
 Source_DB   Source_TBL   Source_Col   Target_DB   Target_TBL   Target_Col   Metric   Source_VAL   Target_Val
____________________________________________________________________________________________________________
Source_D    Source_T     Col1         Target_D    Target_T     Col1         Index    1            1
Source_D    Source_T     Col1         Target_D    Target_T     Col1         Scale    4            4


A: NOT EXISTS solution. You may need to add some conditions the sub-query's WHERE:
select t1.*
from table1 t1
where NOT EXISTS (select 1 from ControlTable ct
                  where t1.Source_DB = ct.DB_NM
                    and t1.Source_TBL = ct.Source_TBL
                    ...
                    and ct.INCLUDE_FLAG = 'N')

(I.e. the ... shall be removed, or replaced with additional conditions.)

A: select SOURCE_DB, SOURCE_TBL, SOURCE_COL, TARGET_DB, Target_TBL, Target_Col, Metric, Source_VAL, Target_Val
from dummy_temp
where metric not in (select metric from dummy_control);

