首页 Oracle Oracle逐行相加

Oracle逐行相加

有时候有这种需求,查出来的结果集要逐行相加。 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

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

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

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/shujuku/oracle/20200715/5962.html
上一篇
下一篇

作者: dawei

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

为您推荐

返回顶部