B
bfreeman
new to sql...
trying to sum two columns from two tables.
Volunteers can earn hours in either TrailPatrol or Jobs. I'm trying to
get a total for all volunteers that have worked both TrailPatrol hours
and JobHours. So...
VolunteerID 117 has earned 1,000 hours overall.
Also, I assume that if a volunteer has no hours worked that it will
return a null value, so i need the null value to become zero...
Here is the code I've been working with:
Code:
--------------------
SELECT Volunteers.VolunteerID,
[LastName] & " ," & [FirstName] AS Expr1,
JobHours.Date, Sum(JobHours.Hours) AS SumOfHours,
Sum(TrailPatrol.Hours) AS SumOfHours1
FROM (Volunteers INNER JOIN (VolunteerJobs INNER JOIN JobHours
ON VolunteerJobs.VolunteerJobID = JobHours.VolunteerJobID)
ON Volunteers.VolunteerID = VolunteerJobs.VolunteerID)
INNER JOIN TrailPatrol ON Volunteers.VolunteerID = TrailPatrol.VolunteerID
GROUP BY Volunteers.VolunteerID, [LastName] & " ," & [FirstName], JobHours.Date
HAVING (((JobHours.Date) Between [Enter begin date:] And [Enter end date:])
AND ((Sum(JobHours.Hours)) Is Not Null));
trying to sum two columns from two tables.
Volunteers can earn hours in either TrailPatrol or Jobs. I'm trying to
get a total for all volunteers that have worked both TrailPatrol hours
and JobHours. So...
VolunteerID 117 has earned 1,000 hours overall.
Also, I assume that if a volunteer has no hours worked that it will
return a null value, so i need the null value to become zero...
Here is the code I've been working with:
Code:
--------------------
SELECT Volunteers.VolunteerID,
[LastName] & " ," & [FirstName] AS Expr1,
JobHours.Date, Sum(JobHours.Hours) AS SumOfHours,
Sum(TrailPatrol.Hours) AS SumOfHours1
FROM (Volunteers INNER JOIN (VolunteerJobs INNER JOIN JobHours
ON VolunteerJobs.VolunteerJobID = JobHours.VolunteerJobID)
ON Volunteers.VolunteerID = VolunteerJobs.VolunteerID)
INNER JOIN TrailPatrol ON Volunteers.VolunteerID = TrailPatrol.VolunteerID
GROUP BY Volunteers.VolunteerID, [LastName] & " ," & [FirstName], JobHours.Date
HAVING (((JobHours.Date) Between [Enter begin date:] And [Enter end date:])
AND ((Sum(JobHours.Hours)) Is Not Null));