Imagine you have been given the task of writing a T-SQL query with running totals of sales by customer. Maybe your first thought is to use a cursor to do it, or possibly you are familiar with some query techniques like self-joins to accomplish the task. If you are running SQL Server 2012 or later, you are in luck! Window functions make it easy to calculate running totals, moving averages, and more.
In this chapter, you will ...