Home » SQL & PL/SQL » SQL & PL/SQL » query
query [message #37373] Sun, 03 February 2002 19:45 Go to next message
Shukla
Messages: 5
Registered: July 2001
Junior Member
hello,

A date query. For eg. There are three tables..

Employee(EmployeeID*, Name)
Department(DeptNo*, EmployeeID, Salary)
and
Salary(Dept*, DatePaid)

Can u pass me a query which calculates Total Salary of an employee of the whole year 1996. Note: an Employee may b involved in many departments and paid seperately.

Thanks,
Shukla
Re: query [message #37378 is a reply to message #37373] Mon, 04 February 2002 03:45 Go to previous messageGo to next message
Jon
Messages: 483
Registered: May 2001
Senior Member
select name, sum(salary)
from (select name, salary, datepaid
from employee e, department d, salary s
where e.employeeId = d.employeeId
and d.deptno = s.deptno)
where to_char(datePaid,'YYYY') = '1996'
group by name;
Re: query [message #37388 is a reply to message #37373] Tue, 05 February 2002 00:30 Go to previous message
Manoj
Messages: 101
Registered: August 2000
Senior Member
SELECT NAME EMP_ID,SUM(SAL)
FROM EMP_TEST T ,DEPT_TEST D WHERE DEPT_NO
IN (SELECT DISTINCT DEP_NO FROM SAL
WHERE TO_CHAR(DDT,'YYYY')='1996')
AND T.EMP_ID= D.EMP_ID GROUP BY NAME
Previous Topic: Partitioning and Optimizer Mode
Next Topic: Linking table fields in oracle
Goto Forum:
  


Current Time: Thu Apr 25 18:32:20 CDT 2024