Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Union sum() 1

Status
Not open for further replies.

fordtran

Programmer
Jun 15, 2005
101
ZA
I am sorry, the search facility is down, but I need help now.

I have two tables named HOURS and OLDHOURS.
Each table has fields HOURSWORKED and HOURSOVERTIME

I need to summarise the hoursworked and the hoursovertime such as in :

Sum(HOURSWORKED)as TOTALHOURSWORKED and sum(HOURSOVERTIME) as TOTALHOURSOVERTIME from the union of tables HOURS and OLDHOURS.

Thanks


fordtran
 
A starting point:
SELECT Sum(hw) AS TOTALHOURSWORKED, Sum(ho) AS TOTALHOURSOVERTIME
FROM (
SELECT Sum(HOURSWORKED) AS hw, Sum(HOURSOVERTIME) AS ho FROM HOURS
UNION ALL SELECT Sum(HOURSWORKED), Sum(HOURSOVERTIME) FROM OLDHOURS
) AS U

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top