Banana
06-30-2008, 11:09 AM
I'm pretty sure I'm having a off day, but I can't wrap my head around this query.
I need to get sums of hour for each month for each clients. Here's my SQL so far.
SELECT
[LastName] & ", " & [FirstName] AS [Client Name],
qtrMonthSorted.Month, 'Names every month in fiscal year order
Sum(tblDuration.Duration) AS [Total Hours]
FROM
qtrMonthSorted,
tblPerson INNER JOIN (tblDuration
INNER JOIN (tblClients
INNER JOIN tblVisit
ON tblClients.PersonID = tblVisit.PersonID)
ON tblDuration.DurationID = tblVisit.DurationID)
ON tblPerson.PersonID = tblClients.PersonID
GROUP BY
[LastName] & ", " & [FirstName],
qtrMonthSorted.Month, qtrMonthSorted.MonthID
ORDER BY
[LastName] & ", " & [FirstName], qtrMonthSorted.MonthID;
My brain says I should be able to add another query to retrieve the Sum() with a WHERE clause to retrieve the current Month # from the qtrMonthSorted, but my guts disagree.
I need to get sums of hour for each month for each clients. Here's my SQL so far.
SELECT
[LastName] & ", " & [FirstName] AS [Client Name],
qtrMonthSorted.Month, 'Names every month in fiscal year order
Sum(tblDuration.Duration) AS [Total Hours]
FROM
qtrMonthSorted,
tblPerson INNER JOIN (tblDuration
INNER JOIN (tblClients
INNER JOIN tblVisit
ON tblClients.PersonID = tblVisit.PersonID)
ON tblDuration.DurationID = tblVisit.DurationID)
ON tblPerson.PersonID = tblClients.PersonID
GROUP BY
[LastName] & ", " & [FirstName],
qtrMonthSorted.Month, qtrMonthSorted.MonthID
ORDER BY
[LastName] & ", " & [FirstName], qtrMonthSorted.MonthID;
My brain says I should be able to add another query to retrieve the Sum() with a WHERE clause to retrieve the current Month # from the qtrMonthSorted, but my guts disagree.