AI engineering glossary · SQL databases

What is PARTITION BY?

PARTITION BY: The part of a window definition that splits rows into independent groups, so the window function restarts in each. Unlike GROUP BY, all rows remain in the output. It appears inside the OVER parentheses.

Level: intermediateTopic: SQL databases

PARTITION BY: an example

RANK() OVER (PARTITION BY city ORDER BY sales DESC) ranks stores separately inside each city.

Related terms

More SQL databases terms

Where you learn it

PARTITION BY is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.