O'Reilly logo

Microsoft® SQL Server® 2012 High-Performance T-SQL Using Window Functions by Itzik Ben-Gan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required