using rank() and window functions in Greenplum
Define and name a window specification. Reuse window specification throughout the query
sachi=# select region,rank() over (order by year) from sachi.sales;
region | rank
--------+------
asia | 1
usa | 2
(2 rows)
^
sachi=# select region, rank() over (W) from sachi.sales WINDOW W as (order by year);
region | rank
--------+------
asia | 1
usa | 2
(2 rows)