Feb 17

rows between unbounded preceding and current row等unbounded ,preceding ,following,current row含义详解 不指定

admin , 23:18 , 数据库 » 数据库(Oracle开发) , 评论(0) , 引用(0) , 阅读(133) , Via 本站原创 | |
搜索
我已经获得阿里云幸运券,准备分享给您。请点击获取  

begin --byitlief365

rows between unbounded preceding and current row等unbounded ,preceding ,following,current row含义详解

unbounded:无界限  by itlife365.com

preceding:从分区第一行头开始,则为 unbounded。 N为:相对当前行向前的偏移量

following :与preceding相反,到该分区结束,则为 unbounded。N为:相对当前行向后的偏移量

current row:顾名思义,当前行,偏移量为0

例子:

partition by  order by asc/desc rows between unbounded preceding and current row

partition by order by asc/desc rows between 1 preceding and 1 following

sql_unbounded_preceding_demo

时间窗口统计:SUM(amt) OVER (PARTITION BY cust_no,class_no ORDER BY amt asc,expate_date asc  ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS amt /*向前汇总累计金额*/

更多:

https://www.cnblogs.com/xiaohuilong/p/6047678.html

end by  --byitlief365