Combining 2 Queries

E

esi

Trying to incorporate 2 left join queries into 1 combined query. Basically
I'm trying to get the total REG hours and OVT hours for each pay period and
each dept. I need to make sure that if hours do not exist for a given pay
period or dept, a null value is shown. I tried to left join Q1 with
qryTotalREGPayroll and qryTotalOVTPayroll in the same query but, I wound up
with results doubling the amount of SumOfTotal_REGHrs. Not sure how to
structure this query.

Left Query 1 Sql:

SELECT Q1.Month, Q1.Period, Q1.[Department Number],
Sum(qryTotalREGPayroll.Total_REGHrs) AS SumOfTotal_REGHrs
FROM Q1 LEFT JOIN qryTotalREGPayroll ON (Q1.[Department Number] =
qryTotalREGPayroll.Dept) AND (Q1.Period = qryTotalREGPayroll.Period)
GROUP BY Q1.Month, Q1.Period, Q1.[Department Number];


Left Query 2 sql:

SELECT Q1.Month, Q1.Period, Q1.[Department Number],
Sum(qryTotalOVTPayroll.Total_OVTHrs) AS SumOfTotal_OVTHrs
FROM Q1 LEFT JOIN qryTotalOVTPayroll ON (Q1.[Department Number] =
qryTotalOVTPayroll.Dept) AND (Q1.Period = qryTotalOVTPayroll.Period)
GROUP BY Q1.Month, Q1.Period, Q1.[Department Number];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

2 Left Join Queries 0
Left Join Queries 0
2 Left Join Queries into 1 0
Joining 2 Left Join Queries 2
Join Query Help 0
Duplicate Query Results 0
Combining two queries into a single query 2
UNION query 11

Top