Index Ai Academy
Glossary · Phase 7 · Software engineering

Window function

Also written: window functions

A SQL calculation across a set of rows, like a rank or a running total, that keeps every row instead of grouping them.

GROUP BY collapses rows. A window function calculates over a set of rows but keeps every row, adding the result beside it. You write it with OVER (...): PARTITION BY says which rows belong together (like a group), and ORDER BY sets the order within them.

Try it now

SQL is written SELECT first but worked out in this order, which is why a WHERE can't use a column alias but ORDER BY can.

Learn it properly

SQL for analysis · Subqueries, CASE, common table expressions, outer joins and window functions on real order data. About 45 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write