T-SQL performance tuning tips Based on SQL Server 2012 window functions Source code and sample database