Is subquery the solution to this?

civicwar

New Member
Here's the table structure and some sample data:\[code\]pID.....month.....year27 .....3 .....200827 .....12 .....201231 .....6 .....200899 .....1 .....200642 .....1 .....2009\[/code\]pID is the practiceID and month and year represent the date period they've entered data for. I need to grab the number of practices that have entered data for the first time in Oct 2012, Nov 2012, Dec 2012 and so on. I tried the following query for Oct 2012:\[code\]SELECT *FROM IPIPKDISwhere practiceID NOT IN ( SELECT practiceID from IPIPKDIS where year < 2012 and month < 10 ) and year = 2012 and month = 10 and measureCatRecID = 2ORDER BY year, month;\[/code\]but it's grabbing months and year less than 10/2012. If I run the queries isolated (not as subquery) they both work fine. Any ideas?
 
Top