Define a reusable window specification with a name in a WINDOW clause, then reference it by name across multiple window functions in the same query. Eliminates duplicated OVER(...) definitions.
Defines window specifications once and reuses them across multiple window functions in the same query, reducing repetition. Particularly useful when the same partition and ordering appears in multiple functions. Improves readability and maintainability.
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | ✓ Supported | 8.0 | WINDOW clause supported since MySQL 8.0. Named windows can be referenced by name in OVER (name) or extended in OVER (name ORDER BY ...) to add or modify clauses. A named window cannot be redefined differently in the same query. ORDER BY and PARTITION BY defined in the named window can be extended but not overridden by the referencing OVER clause. |
| PostgreSQL | ✓ Supported | 8.4 | WINDOW clause fully supported since PostgreSQL 8.4 — the earliest of any engine. Named windows can be extended with additional ORDER BY or frame clauses in the referencing OVER clause but cannot change the existing PARTITION BY or ORDER BY. Multiple named windows can be defined, and one named window can reference another (inheritance). |
| SQL Server | ✗ Not Supported | — | SQL Server does not support the WINDOW clause. Named window definitions cannot be declared and reused. Each window function must repeat its full OVER (...) specification. If multiple window functions share the same OVER clause, the optimizer may still recognize and reuse the window internally, but the syntax must be duplicated. |
| Oracle | ✗ Not Supported | — | Oracle does not support the SQL standard WINDOW clause. Each window function requires its own full OVER (...) specification. The optimizer may internally recognize and share window computation for identical OVER clauses, but the syntax still requires repetition. |
| SQLite | ✓ Supported | 3.28.0 | WINDOW clause supported since SQLite 3.28.0 (2019-04-16). Standard syntax — named windows can be defined and referenced, and they can be extended (but not overridden) in the referencing OVER clause. |
The WINDOW clause is part of the SQL standard and is supported by PostgreSQL (8.4+), MySQL (8.0+), and SQLite (3.28.0+). SQL Server and Oracle omit it entirely — both require repeating the full OVER() specification for every window function. The practical impact is significant: a query with five window functions all sharing the same partition/order must duplicate that definition five times in SQL Server and Oracle. PostgreSQL supports named window inheritance — one named window can build on another — which MySQL and SQLite do not support. Even without the WINDOW clause, SQL Server and Oracle's optimizers typically recognize identical OVER() clauses and compute the window only once in the execution plan.
WINDOW clause supported since MySQL 8.0. Named windows can be referenced by name in OVER (name) or extended in OVER (name ORDER BY ...) to add or modify clauses. A named window cannot be redefined differently in the same query. ORDER BY and PARTITION BY defined in the named window can be extended but not overridden by the referencing OVER clause.
WINDOW clause fully supported since PostgreSQL 8.4 — the earliest of any engine. Named windows can be extended with additional ORDER BY or frame clauses in the referencing OVER clause but cannot change the existing PARTITION BY or ORDER BY. Multiple named windows can be defined, and one named window can reference another (inheritance).
SQL Server does not support the WINDOW clause. Named window definitions cannot be declared and reused. Each window function must repeat its full OVER (...) specification. If multiple window functions share the same OVER clause, the optimizer may still recognize and reuse the window internally, but the syntax must be duplicated.
Oracle does not support the SQL standard WINDOW clause. Each window function requires its own full OVER (...) specification. The optimizer may internally recognize and share window computation for identical OVER clauses, but the syntax still requires repetition.
WINDOW clause supported since SQLite 3.28.0 (2019-04-16). Standard syntax — named windows can be defined and referenced, and they can be extended (but not overridden) in the referencing OVER clause.