Appearance
WINDOW Clause
Use the WINDOW
clause as a shortcut to define the same behavior for multiple window functions in the same query.
[ WINDOW window_name AS ( window_definition ) [, ...] ]
In this context, the window_definition
is the contents of the OVER
clause, not including the OVER
keyword.
For example:
premdb=# select name, city,
sum(capacity) over w,
max(capacity) over w
from team
window w as (partition by city order by capacity);
name | city | sum | max
-------------------------+---------------+--------+-------
Barnsley | Barnsley | 23009 | 23009
West Bromwich Albion | Birmingham | 27000 | 27000
Birmingham City | Birmingham | 57016 | 30016
Aston Villa | Birmingham | 99801 | 42785
Blackburn Rovers | Blackburn | 31367 | 31367
Blackpool | Blackpool | 17338 | 17338
Bolton Wanderers | Bolton | 28723 | 28723
Bournemouth | Bournemouth | 11464 | 11464
Bradford City | Bradford | 25136 | 25136
Burnley | Burnley | 22546 | 22546
...
Parent topic:SELECT