Results 1 to 3 of 3

Thread: calculating the sum of a field in a query with join

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Answers
    18

    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.

  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: calculating the sum of a field in a query with join

    please post both of your tables structures for further details.


  3. #3
    Expert Member
    Join Date
    Jun 2006
    Answers
    410

    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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact