November 2019
Intermediate to advanced
352 pages
12h 27m
English
The first five chapters of this book described window functions in detail, including both their logical aspects and their optimization aspects. In this sixth and last chapter of the book, I’m going to show how to solve a wide range of querying tasks 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
■ Emulating IGNORE_NULLS
■ Mode
■ Trimmed mean
■ Running totals ...