有时候有这种需求,查出来的结果集要逐行相加。

create table t

( id number,value number ); insert into t values(1,10); insert into t values(2,10); insert into t values(3,20); insert into t values(4,20); insert into t values(5,30); insert into t values(6,30); commit; SQL> select * from t; ID VALUE ---------- ---------- 1 10 2 10 3 20 4 20 5 30 6 30 SQL> select id,value,sum(value)over(order by id asc rows between unbounded preceding and current row) s_value from t; ID VALUE S_VALUE ---------- ---------- ---------- 1 10 10 2 10 20 3 20 40 4 20 60 5 30 90 6 30 120

dawei

【声明】:淮南站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。