
- Forum
- Databases
- Oracle calculating the sum of a field in a query with join
-
Junior Member
calculating the sum of a field in a query with join
Select attend.overtimehours from attendance attend, salarydetail sal where attend.employeeid = sal.employeeid
in the above query,how can i fetch the sum of overtimehours?
attendance table
column_name data_type
-------------------- -------------------
attendancerid number
employeeid number
shiftid number
dayofattendance date
timein date
timeout date
numberofhours number
overtimehours number
presentflag varchar2
salarydetail table
column_name data_type
----------------- --------------------
salaryid number
employeeid number
startdate date
enddate date
grosssalary number
netsalary number
overtimeamount number
lopamount number
paiddays number
Last edited by jamesravid; 09-05-2007 at 12:14 PM.
-
Re: calculating the sum of a field in a query with join
please post both of your tables structures for further details.
-
Expert Member
Re: calculating the sum of a field in a query with join
If you need only sum of overtime hours then the following query works for u
Select employeeid,sum(overtimehours )
from attendance
group by employeeid
If u want bothe sum of overtime and overtime amount then use the following query,
Select attend.employeeid, sum(attend.overtimehours),sum(sal.overtimeamount)
from attendance attend, salarydetail sal
where attend.employeeid = sal.employeeid
group by attend.employeeid
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules