Given data like this:
SHQSCriteria PropertyRef ReplacementYear
Energy Efficient 31 2014/15
Healthy, Safe & Secure 31 2012/13
Energy Efficient 462 2014/15
Healthy, Safe & Secure 462 2012/13
Free From Serious Disrepair 497 2012/13
Healthy, Safe & Secure 497 2012/13
Tolerable Standard 497 2012/13
Free From Serious Disrepair 498 2012/13
Healthy, Safe & Secure 498 2013/14
Tolerable Standard 498 2014/15
I want to pull out all the properties that fail more than one criterion, with the year that they fail the second criterion.
So, I want records that appear in the above list at least twice, but the replacement year is the second chronologically. Like this:
PropertyRef ReplacementYear
31 2014/15
462 2014/15
497 2012/13
498 2013/14
Please note that in this example properties 497 and 498 both fail three criteria. 497 fails all in the same year, so we should return that year. But 498 fails in 3 different years so we should return the second year.