Hi,I have 2 tables. I need to find per idno in table tmpProcess the consecutive months following the mxdate in table #cte but less than the mnDate. If the mxdate is 2012-07 in table CTE but the month following that is 2012-09 then it's not relevant. Only if the months following that start from 2012-08.Any thoughts on how to do that?ThanksCREATE TABLE #CTE (IDNO INT,MNDATE DATETIME,MXDATE DATETIME) INSERT INTO #CTE VALUES ( 307,'2012-06-01 00:00:00.000','2012-07-01 00:00:00.000' )INSERT INTO #CTE VALUES ( 307,'2012-11-01 00:00:00.000','2013-03-01 00:00:00.000' )INSERT INTO #CTE VALUES (656,'2013-07-01 00:00:00.000', '2013-08-01 00:00:00.000')CREATE TABLE #tmpProcess (IDNO INT,ACTUALDATE DATETIME)INSERT INTO #tmpProcess VALUES (307,'2012-08-01 00:00:00.000')INSERT INTO #tmpProcess VALUES (307,'2012-09-01 00:00:00.000')INSERT INTO #tmpProcess VALUES (307,'2013-04-01 00:00:00.000')INSERT INTO #tmpProcess VALUES (307,'2013-06-01 00:00:00.000')INSERT INTO #tmpProcess VALUES (656,'2013-10-01 00:00:00.000')INSERT INTO #tmpProcess VALUES (656,'2013-11-01 00:00:00.000')INSERT INTO #tmpProcess VALUES (656,'2013-12-01 00:00:00.000')outputSELECT 307,'2012-08-01 00:00:00.000', '2012-06-01 00:00:00.000','2012-07-01 00:00:00.000'UNIONSELECT 307,'2012-09-01 00:00:00.000', '2012-06-01 00:00:00.000','2012-07-01 00:00:00.000'UNIONSELECT 307,'2013-04-01 00:00:00.000', '2012-11-01 00:00:00.000','2013-03-01 00:00:00.000'