SELECT - WINDOW clause
declares reusable named window specifications (PARTITION BY, ORDER BY, frame)
What changes
- Input
- window specifications
- Output or change
- named windows used by OVER clauses
Syntax at a glance
WINDOW window_name AS ( [ reference_window_name ] [ <PARTITION BY clause> ] [ <ORDER BY clause> ] [ <ROW or RANGE clause> ] )
Work example
A query needs a named window definition reused by more than one window expression.
Define partition and ordering once, then compare each expression that refers to the window.
Check your work SELECT - WINDOW clause. All expressions use the same named window rules and the detail row count stays unchanged.
Open Microsoft Learn for full syntax, permissions, and details for your version.