• If you are on Sql Server 2012 or 2014, you should definitely look into the over clause and the window functions, perfect for this type of work.

    😎