Window name clause
Defines a named window that specifies window partition and order clauses for an analytic function. This window is specified in the function's OVER clause. Named windows can be useful when you write queries that invoke multiple analytic functions with similar OVER clauses—for example, they use the same partition (PARTITION BY) clauses.
Syntax
WINDOW window-name AS ( window-partition-clause [window-order-clause] )
Parameters
WINDOWwindow-name- Specifies the window name. All window names must be unique within the same query.
window-partition-clause `[`
window-order-clause`]`
: Clauses to invoke when an `OVER` clause references this window.
If the window definition omits a window order clause, the OVER clause can specify its own order clause. **
Requirements
-
A
WINDOWclause cannot include a window frame clause. -
Each
WINDOWclause within the same query must have a unique name. -
A
WINDOWclause can reference another window that is already named. For example, the following query names windoww1beforew2. Thus, theWINDOWclause that definesw2can referencew1:=> SELECT RANK() OVER(w1 ORDER BY sal DESC), RANK() OVER w2 FROM EMP WINDOW w1 AS (PARTITION BY deptno), w2 AS (w1 ORDER BY sal);
Examples
See Named windows.