IntroductionIn this tip,i will explain how to get the running total in oracle. select
ename,
dname,
sal,
sum(sal) over (partition by dname) dept_wise_total,
sum(sal) over (partition by dname order by dname, ename) deptwise_running_total,
sum(sal) over () total,
sum(sal) over (order by dname, ename) running_total
from
scott.emp e,
scott.dept d
where
e.deptno=d.deptno
order by
dname, enameSimulated Version select
ename,
dname,
sal,
sum(sal) over (partition by dname order by dname, ename) deptwise_running_total,
(select sum(sal) from scott.emp b where b.deptno=e.deptno and b.ename <= e.ename) sim_dept_runtotal,
sum(sal) over (order by dname, ename) running_total,
(select sum(sal) from scott.emp b where b.ename <= e.ename) sim_running_total
from
scott.emp e,
scott.dept d
where
e.deptno=d.deptno
order by
dname, enameOutput thank you for reading. |