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
Re: calculating the sum of a field in a query with join
please post both of your tables structures for further details.
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