Oracle逐行相加
发布时间:2020-07-16 05:20:14 所属栏目: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(编辑:岳阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Oracle笔记 八、PL/SQL跳转/判断/循环语句块
- 如何确定Oracle数据库表重复的记录
- Oracle 11g RAC for LINUX rhel 6.X silent install(静默安
- Oracle 自增(auto increment) 或 标识字段的建立方法
- Oracle12.2 RAC集群管理之IP地址修改_Oracle12cR2视频教程(
- Oracle BULK COLLECT批量取数据解决方法
- Oracle 8i在P4上的安装
- 赵强老师:免费实战微课系列课程
- 浅谈ORACLE AWR single instance 一
- 安装oracle11g INS-30131执行安装程序验证所需的初始设置失