I have below query which is not returning expected output result. For NAME
column with value='PL'
it should check the data in M_LOG
table with NAME
and E_ID
column values combination and check if this combination value exist in DIR_LOG
table. If it does not exist the query should return only those combination values.
Currently the query is returning all the combination value which is already exist in M_LOG
table. I think i am missing small condition somewhere is query.
Select MAX(ML.NAME), ML.E_ID, CASE --If the day of the month is the 1st, 2nd or 3rd then it will use the last day of the previous month otherwise it will use the last day of the current month
WHEN EXTRACT( DAY FROM SYSDATE ) <= 3
THEN TRUNC( SYSDATE, 'MM' ) - INTERVAL '1' DAY
ELSE LAST_DAY( TRUNC( SYSDATE ) ) END, 1, 'M1' from DIR_LOG ML, M_LOG MD
WHERE ML.NAME != MD.NAME and ML.E_ID != MD.E_ID and
ML.NAME = 'PL'
GROUP BY ML.E_ID