我尝试使用查询来计算字段中的行之间的差异:
Illustrations: input:year,month,fixes output:increase year | month | fixes | increase ------+-------+----------+----------- 2006 | 04 | 1 | 0 2006 | 05 | 4 | 3 2006 | 06 | 3 | -1
这是什么窗口功能是:
select year,fixes,fixes - lag(fixes) over (order by year,month) as increase,from the_table;
有关详细信息,请参阅手册:
http://www.postgresql.org/docs/current/static/tutorial-window.html