Comparing current Month and previous Month's rows on a column, SQL Server 2012
问题 I need some guidance and help with a question I am not entirely sure how to solve in SQL Server 2012. I think LAG and LEAD functions could be useful but I am not sure. This is what my data looks right now: ========================================= YearMonth LocationCode Active ========================================= 201405 123 0 201406 123 2 201409 211 1 201410 211 0 201411 214 0 201412 214 3 We have a YearMonth column that shows how the status looked like for each locationCode and an