liveBook · Manning

Window function

A window function is an SQL operation that computes a value over related rows while preserving each individual row in the result.

How 3 Manning books explain it

The Well-Grounded Data Analyst

A window function is a SQL operation that computes a result over related rows while retaining each row in the query result.

How it is used
Compares each hour’s cycling count with its location’s daily total for time-of-day analysis.
How deep it goes
Demonstrates a practical pandas transform workflow and verification step, without detailing SQL window-function syntax beyond PARTITION BY.
Examples
Uses hourly bicycle counts by location and date to compute each hour’s percentage of daily cycling traffic.
What you can do after
Apply it via pandas transform to append group totals and calculate row-level percentages.

Read how The Well-Grounded Data Analyst explains window function →

DuckDB in Action

A window is a defined set of rows over which a SQL window function computes a value for each current row.

How it is used
Supports analytical SQL workflows for ranking, comparisons, running totals, and partition-level metrics while retaining detailed rows.
How deep it goes
Defines OVER, partitions, ordering, and frames, then demonstrates ranking and row comparisons; detailed frame variations remain limited.
Examples
Demonstrates power-reading top-n queries, per-system averages, and month-by-month renewable-energy price changes.
What you can do after
Apply it via DuckDB SQL to rank partitions, calculate windowed aggregates, compare adjacent rows, and filter computed results.

Read how DuckDB in Action explains window function →

Just Use Postgres!

A window function computes a value over a set of rows related to the current row without collapsing those rows into a single aggregate result.

How it is used
Applies row-preserving calculations to analyze song preferences, popularity, rankings, running totals, and related streaming data.
How deep it goes
Defines windows, contrasts them with GROUP BY aggregates, and demonstrates partitioning, ordering, running totals, and ranking.
Examples
Demonstrates song totals by user, running play-duration totals, and song rankings using streaming-play data.
What you can do after
Apply via PostgreSQL to write readable queries that calculate grouped, cumulative, and ranked values without collapsing detail rows.

Read how Just Use Postgres! explains window function →

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.