I have to a table like this
Year Month
2012 8
2012 7
2012 4
2012 3
2011 7
2011 3
2011 1
2010 10
2010 9
2010 8
This tables show which month and year is remaning, now let say I have completed 2012, 7 month. Now I want to have list like
Year Month
2012 8
2012 4
2012 3
2011 7
2011 3
2011 1
2010 10
2010 9
2010 8
I am using below query but this is not giving me the correct records
SELECT YEAR, MONTH from tablex
WHERE Year NOT IN (SELECT DISTINCT YEAR from OTHER_TABLE INNER JOIN Some_Other_Table)
AND MONTH NOT IN (SELECT DISTINCT MONTH FROM OTHER_TABLE INNER JOIN Some_Other_Table)
When OTHER_TABLE is null then I am getting the currect count, but when Other table has year 2012 and month 7 I am getting no results.
P.S.: There is no joining columns available for tablex and OTHER_TABLE and Som_Other_Table
You just have to use
NOT EXISTS: