For below query we require one more column that will hold cumulative values for salary :
select * from emp ;
NAME SAL
----------------
lalit 5
sandeep 10
rahul 10
pravin 17
Query :
SELECT b.name, b.sal, SUM (a.sal) AS cum_sal
FROM emp a, emp b
WHERE a.ROWID <= b.ROWID
GROUP BY b.name, b.ROWID, b.sal;
queryoutput
NAME SAL CUM_SAL
------------------
lalit 5 5
rahul 10 25
pravin 17 42
sandeep 10 15
No comments:
Post a Comment