Window function
A window function is an SQL operation that computes a value over related rows while preserving each individual row in the result.
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.
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.
Related concepts
- over clausehas part · An OVER clause defines the partitioning, ordering, and frame specification that determines the rows processed by a SQL window function.
- order by clauseconfigured by · An ORDER BY clause specifies the ordering of query results according to one or more expressions, fields, or sort directions.
- rolling windowincludes · A rolling window is a fixed-size or fixed-duration subset that moves across sequential data or time for repeated analysis or computation.
- pct_changeincludes · pct_change is a pandas method that computes fractional or percentage changes between successive values along an axis.
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.


