ANSI SQL2003’s Window Syntax
SQL2003 specifies the following syntax for window functions:
FUNCTION_NAME
(expr
) OVER {window_name
| (window_specification
)}window_specification
::= [window_name
] [partitioning
] [ordering
] [framing
]partitioning
::= PARTITION BYvalue
[,value
...] [COLLATEcollation_name
]ordering
::= ORDER [SIBLINGS] BYrule
[,rule
...]rule
::= {value
|position
|alias
} [ASC | DESC] [NULLS {FIRST | LAST}]framing
::= {ROWS | RANGE} {start
|between
} [exclusion
]start
::= {UNBOUNDED PRECEDING |unsigned-integer
PRECEDING | CURRENT ROW}between
::= BETWEENbound
ANDbound
bound
::= {start
| UNBOUNDED FOLLOWING |unsigned-integer
FOLLOWING}exclusion
::= {EXCLUDE CURRENT ROW | EXCLUDE GROUP | EXCLUDE TIES | EXCLUDE NO OTHERS}
Get SQL in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.