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.
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
- Phantom read
- PostgreSQL
- Primary key
- Query optimizer
- RANK and DENSE_RANK
- Recursive CTE
- Referential integrity
- Relational algebra
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.