Skip to Main Content
T-SQL Window Functions: For data analysis and beyond, 2nd Edition
book

T-SQL Window Functions: For data analysis and beyond, 2nd Edition

by Itzik Ben-Gan
November 2019
Intermediate to advanced content levelIntermediate to advanced
352 pages
12h 27m
English
Microsoft Press
Content preview from T-SQL Window Functions: For data analysis and beyond, 2nd Edition

CHAPTER 6

T-SQL Solutions Using Window Functions

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SQL for Data Analysis

SQL for Data Analysis

Cathy Tanimura

Publisher Resources

ISBN: 9780135861554