Recommended books
Microsoft SQL Server 2012 High-Performance T-SQL Using Window Functions
Window functions are a special construct in the SQL language that allow you to easily calculate more complex requirements, such as year-to-date calculations, moving averages, percentiles and so on.