首页 新闻 搜索 专区 学院

oracle分析函数

0
悬赏园豆:5 [待解决问题]

查询:
with t as
(select rownum id, column_value value from table(sys.odcinumberlist (1,2,3,4.5,4.6,7,10)))
select t.*,
last_value(value) over (order by value range between unbounded preceding and 1 preceding) l1,
last_value(value) over (order by value rows between unbounded preceding and 1 preceding) l2
from t;
结果:
1 1
2 2 1 1
3 3 2 2
4 4.5 3 3
5 4.6 3 4.5
6 7 4.6 4.6
7 10 7 7

有没有大佬解释一下右边的那个3是怎么来的,最好能具体一点的说下值怎么来的,感谢感谢。
又比如取前2行:
with t as
(select rownum id, column_value value from table(sys.odcinumberlist (1,2,3,4.5,4.6,7,10)))
select t.*,
last_value(value) over (order by value range between unbounded preceding and 2 preceding) l1,
last_value(value) over (order by value rows between unbounded preceding and 2 preceding) l2
from t;

1 1
2 2
3 3 1 1
4 4.5 2 2
5 4.6 2 3
6 7 4.6 4.5
7 10 7 4.6
这里的这个2是怎么来的呢

矜持先森么么哒的主页 矜持先森么么哒 | 初学一级 | 园豆:4
提问于:2020-08-03 11:49
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册