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.
Also covered in
What to know first
- SQLSQL is a standardized declarative language for defining, querying, and manipulating data in relational database systems.
- common table expressionA common table expression is a named temporary query result defined within a SQL statement and available for reference by that statement.
- data aggregationData aggregation is the process of combining multiple data values, records, or observations into a consolidated or summarized result.
- order by clauseAn ORDER BY clause specifies the ordering of query results according to one or more expressions, fields, or sort directions.
Related concepts
- data aggregationcontrasts with · Data aggregation is the process of combining multiple data values, records, or observations into a consolidated or summarized result.
- lagused by · A lag is a temporal or positional offset that associates an observation with an earlier observation in an ordered sequence or time series.
- order by clauseconfigured by · An ORDER BY clause specifies the ordering of query results according to one or more expressions, fields, or sort directions.
- over clausehas part · An OVER clause defines the partitioning, ordering, and frame specification that determines the rows processed by a SQL window function.
Questions about window function
What is window function?
A window function is an SQL operation that computes a value over related rows while preserving each individual row in the result.
Which Manning books explain window function?
The Well-Grounded Data Analyst, DuckDB in Action and Just Use Postgres!.
What should I know before learning window function?
Manning books that teach window function usually introduce SQL, common table expression, data aggregation and order by clause first.
What is the difference between window function and data aggregation?
A window function is an SQL operation that computes a value over related rows while preserving each individual row in the result. Data aggregation is the process of combining multiple data values, records, or observations into a consolidated or summarized result.
What kinds of window function are there?
Kinds of window function include expanding window.
What are the parts of window function?
Window function includes over clause and partition by.
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.


