In the emp table :> > EMPNO ENAME SAL > ==================> 7369 SMITH 1000 > 7499 ALLEN 2000 > 7521 WARD 3000 > 7566 JONES 4000 > 7654 MARTIN 5000> > there is a requirement to have a calculated col.> called cummulative sal> > EMPNO ENAME SAL CUMMULATIVE_SAL> 7369 SMITH 1000 1000> 7499 ALLEN 2000 3000> 7521 WARD 3000 6000> 7566 JONES 4000 10000> 7654 MARTIN 5000 15000> > How to show this calculated col. by using one> select statement?

  
Showing Answers 1 - 2 of 2 Answers

Suraj Marathe

  • May 9th, 2006
 

select empno,ename,sal,(select sum(sal) from emp e1 where e1.rowid<=e.rowid) COMMULATIVE_SAL from emp e

  Was this answer useful?  Yes

sunil

  • Jun 8th, 2006
 

select empno,ename,sal, sum(sal)
over(order by empno ) cum_sal
 from emp

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions