liveBook · Manning

Pivoting

Pivoting is a relational data transformation that converts distinct row values into columns, typically aggregating associated values.

How 2 Manning books explain it

DuckDB in Action

A pivot is a relational transformation that turns distinct values from rows into columns, typically while aggregating associated values.

How it is used
Reorganizes grouped analytical results into spreadsheet-style columns for reports and downstream consumption.
How deep it goes
Defines row-to-column transformation, demonstrates filtered aggregates and dynamic PIVOT, then extends to multiple aggregates.
Examples
Uses energy production by system and year, daily power by date, and total-versus-best-day measures.
What you can do after
Build pivoted DuckDB reports with filtered aggregates or dynamic PIVOT, including date columns and multiple measures.

Read how DuckDB in Action explains pivoting →

100 SQL Server Mistakes and How to Avoid Them

The PIVOT operator transforms grouped row values into columns while applying an aggregation to associated values.

How it is used
Produces horizontal reports from grouped relational data, such as stock totals by product category.
How deep it goes
Shows the source query, aggregate, and explicit output-column list, while contrasting the result with cursor implementation and cost.
Examples
Uses MagicChoc product stock, named category columns, and equivalent cursor and PIVOT implementations.
What you can do after
Apply it via T-SQL PIVOT to build grouped horizontal reports without row-by-row cursor updates.

Read how 100 SQL Server Mistakes and How to Avoid Them explains pivoting →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.