Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Challenging Query: Cummmulative Salary 1

Status
Not open for further replies.

UDIT

Technical User
Nov 24, 2000
37
US
hi there,
i ve been trying to figure out how to solve this query but havent found any success as yet , could anyone help:

ques: To write down a query to calculate the cummulative sal of an employee i.e along with the employeeid,employee name,sal,CUMMULATIVE SAL --column should also come as output(Computed column of course)
empid ename sal c_sal
eg: aad1122 bobby 2000 2000
asd344 celina 5000 7000 --(5000+2000)
234f5r jack 6000 13000 --(7000+6000)

thanks,
Udit
 
Could you do this as a PL/SQL Block instead and use dbms_output to mimic the output? It would be alot easier then.
 
hey guys,
i have been able to solve it through pl/sql program but my senior DBA says , HE WANTS A QUERY !!! , so please help. Thanks

( thanks for the advise Mike )
 
Empid looks like a unique key for your table. If so the following join should work. I bet the performance will be poor, however, unless your table is reasonably small. The number of rows in the join is proportional to the square of the number of rows in the table.

select a.empid, a.ename, a.sal, sum(b.sal) as c_sal
from your_table a, your_table b
where a.empid >= b.empid
group by a.empid, a.ename, a.sal
order by a.empid;
 
Thanks a lot Karluk , the solutions GREAT , ya the table is indeed small . Thanks again , but i am posting another query , hope you and Mike would help again. Thanks Guys.
 
Can someone give me a pl/sql program on this cummulative thing ....:)

thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top