Window functions allow you to apply calculations against “sets” or groups of data. These sets are known as windows. Many books classify window functions as an advanced topic in T-SQL. But in fact, once you see some practical examples window function are fairly easy to understand. In this video I will demonstrate how to
- Rank rows (both dense ranks and “normal” ranks.
- Add row numbers.
- Create running / Cumulative totals
- Extract the first and last records from a set (window) of records.
The sample database & T-SQL code used in the tutorial can be downloaded here