Chapter 5. T-SQL Solutions Using Window Functions

The first four chapters of this book described window functions in detail, including both their logical aspects and their optimization aspects. In this fifth and last chapter of the book, I’m going to show how to solve a wide range of querying problems using window functions. What could be surprising to some is the large number of solutions that rely on the ROW_NUMBER function—by far the most commonly used of the bunch.

The solutions covered in this chapter are Virtual Auxiliary Table of Numbers, Sequences of Date and Time Values, Sequences of Keys, Paging, Removing Duplicates, Pivoting, Top N Per Group, Mode, Running Totals, Max Concurrent Intervals, Packing Intervals, Gaps and Islands, Median, ...

Get Microsoft® SQL Server® 2012 High-Performance T-SQL Using Window Functions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.