033.mysql-mysql8-sum开窗函数实现累加

select 
occur_period
,area_code
,index_code
,r
,gxl
,sum(gxl) over(order by r  asc rows between unbounded preceding and current row ) as gxl_lj 
from
tabl01

CURRENT ROW 当前行

UNBOUNDED PRECEDING 边界永远第一行

unbounded following  表示边界永远为最后一行

参考博客

https://segmentfault.com/a/1190000039083467

原文地址:https://www.cnblogs.com/star521/p/15090745.html