mw112009 - Monday, February 5, 2018 12:01 PM
THIS DOES NOT WORK. You haven't bothered to understand what this is doing, and you are not validating your results that you do get. For instance, with this amended data, there is no gap, but this so-called solution is saying that there is a gap of eleven months
INSERT INTO #t(BeneficiaryID, EligYear, EligMonth )
Select '0068576102',2016,6 UNION
Select '0068576102',2016,7 UNION
Select '0068576102',2016,8 UNION
Select '0068576102',2016,9 UNION
Select '0068576102',2016,10 UNION
Select '0068576102',2016,11 UNION
Select '0068576102',2016,12 UNION
Select '0068576102',2017,1 UNION
Select '0068576102',2017,2 UNION
Select '0068576102',2017,3 UNION
Select '0068571234',2017,4 UNION
Select '0068571234',2017,5
The reason that this code doesn't work is that it depends on numbers that are sequential, but you're IGNORING THE YEAR, which means that the month numbers are cyclical, not sequential.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA