Chapter 7

T-SQL for data analysis

This chapter focuses on using T-SQL for data analysis needs. It starts with the powerful window functions, which you can use to apply data-analysis calculations in a flexible and efficient manner. It then covers techniques for pivoting and unpivoting data. Pivoting rotates data from a state of rows to columns, and unpivoting rotates data from columns to rows, similar to pivot tables in Excel. The chapter then continues with a discussion about grouping sets, which are the sets of expressions that you group the data by. It covers techniques for defining multiple grouping sets in the same query. The chapter finishes with coverage of handling of time series data.

Window functions

A window function is a function ...

Get T-SQL Fundamentals, 4th Edition 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.