Transact-SQL does Windows
According to Itzik Ben-Gan: “Windowing functions are the best thing to happen since sliced bread”. In SQL Server 2005, Microsoft introduced SQL Windowing into Transact-SQL with new ranking functions and existing aggregate functions. This gave the Transact-SQL developer the ability to easily generate row numbers and compute sums, averages, etc. while returning detailed data rows. But the ANSI/ISO SQL standard had defined additional windowing functionality and SQL Server 2012 now supports more of it. This includes the ability to frame the scope of the window and new functions like LAG, LEAD, FIRST_VALUE and LAST_VALUE. These enhancements extend the set-based functionality of Transact-SQL.