How do I create named window partitions (aliases) in PostgreSQL?

元气小坏坏 提交于 2019-12-05 19:16:18

The answer was actually in the SELECT doc:

WINDOW Clause

The optional WINDOW clause has the general form

WINDOW window_name AS ( window_definition ) [, ...]

Here is an example,

SELECT first_value(vin) OVER w,
  first_value(make) OVER w
FROM inventory.vehicles
WHERE lot_Id = 9999
  AND make is not null
WINDOW w AS ( PARTITION by vin );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!