PostgreSQL 的gram.y 中所说的 window_clause, 与 window 函数不同。

是一定要出现在 语句最后的:

create table a8(id integer, name varchar(10), salary integer);

insert into a8 values(1, 'aa', 1000);
insert into a8 values(2, 'bb', 3000);
insert into a8 values(3, 'cc', 2000);
insert into a8 values(4, 'dd', 5000);
insert into a8 values(5, 'ee', 2000);
insert into a8 values(6, 'ff', 4000);
insert into a8 values(2,'gg',2000);

SELECT
id, name, first_value(id) OVER w
FROM a8
WHERE salary>1000
WINDOW w AS ( PARTITION by id);

查询结果:

id name first_value
2   aa   2
2   gg   2
3   cc   3
4   dd   4
5   ee   5
6   ff     6