Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Cumulating Salary

Could you please send me the query for Finidng the Cumulative Salary in Oracle..
rgds
Hakkeem.
[107 byte] By [hakkeem] at [2007-11-9 21:09:47]
# 1 Re: Cumulating Salary
"hakkeem" <hak_shaolin@yahoo.com> wrote:
>
>Could you please send me the query for Finidng the Cumulative Salary in
Oracle..
>
>rgds
>Hakkeem.

Hakkeem,

I'm not sure what you mean, but a query to find the sum of a column called
'salary' in a table called 'Employee' would be:

SELECT sum(salary) FROM Employee

If you mean the amount actually paid to an employee, then the query might
look something like:

SELECT sum(gross_pay) FROM Payments WHERE Employee_Id = <id>

For all employees, you would join the two tables on employee id:

SELECT e.name, sum(p.gross_pay)
FROM Employee e JOIN Payments p ON p.Employee_Id = e.Employee_Id
GROUP BY e.name

Hope this helps.
Simon.
Simon Sellick at 2007-11-11 23:53:15 >