Editor's Note: This article has been removed.
It has been brought to our attention that large portions of this article were plagiarized from Itzik Ben-Gan's Microsoft SQL Server 2012 HIgh-Performance T-SQL Using Window Functions.
We apologize to Mr. Ben Gan for the oversight.
We do encourage you to purchase his book if you are interested in Window functions and how they can be used in T-SQL to improve your code readability and performance.