Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

calculating the sum of a field in a query with join

This is a discussion on calculating the sum of a field in a query with join within the Oracle forums, part of the Databases category; 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 ...

Go Back   Geeks Talk > Databases > Oracle
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Oracle Oracle 9i & Oracle 10g Knowledge Base Learn and Share Oracle Technology related articles, white papers, tutorials / study materials, example codes, FAQ's, Tips and Tricks.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-05-2007
Junior Member
 
Join Date: Aug 2007
Posts: 22
Thanks: 4
Thanked 0 Times in 0 Posts
3roses is on a distinguished road
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 01:14 PM.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-05-2007
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,853
Thanks: 9
Thanked 168 Times in 142 Posts
debasisdas has a spectacular aura aboutdebasisdas has a spectacular aura about
Re: calculating the sum of a field in a query with join

please post both of your tables structures for further details.
Reply With Quote
  #3 (permalink)  
Old 09-05-2007
Expert Member
 
Join Date: Jun 2006
Location: India
Posts: 413
Thanks: 15
Thanked 43 Times in 31 Posts
jamesravid will become famous soon enough
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
__________________
Cheers,
:) James:)
Reply With Quote
Reply

  Geeks Talk > Databases > Oracle

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Writing query with LEFT OUTER JOIN N SRIRAM K Data Warehousing 5 09-03-2007 06:08 AM
Join Query without using NOT IN subquery Geek_Guest SQL 1 03-07-2007 04:24 PM
Are you Good in Calculating!!!! If so Try this (2) psuresh1982 Brainteasers 3 09-13-2006 09:38 AM
Are you Good in Calculating!!!! If so Try this sripri Brainteasers 2 09-12-2006 03:24 AM
Try Calculating StephenRaj Brainteasers 2 08-20-2006 01:12 AM


All times are GMT -4. The time now is 01:30 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved