I've trying to produce a crosstab query with employee numbers as the row headings, billed activities for the columns, and duration sums as the values. When I run the code below, the output is correct and shows all activities, even activities with no hours billed to them:
However, when I add criteria to limit the date range as below, the query stops returning all activities, and only returns those with records.
How do I tell Access to continue to return ALL activity column headings? I'm sure that this question has been asked before, but I can't see how to apply the answers to my specific code.
Code:
TRANSFORM Format(Sum(tbl_Timesheets.Duration),"Fixed") AS SumOfDuration
SELECT tbl_Timesheets.SAP_HRNumber
FROM tbl_Activities LEFT JOIN tbl_Timesheets ON tbl_Activities.Activity = tbl_Timesheets.Activity
GROUP BY tbl_Timesheets.SAP_HRNumber
PIVOT tbl_Activities.Activity;
Code:
TRANSFORM Format(Sum(tbl_Timesheets.Duration),"Fixed") AS SumOfDuration
SELECT tbl_Timesheets.SAP_HRNumber
FROM tbl_Activities LEFT JOIN tbl_Timesheets ON tbl_Activities.Activity = tbl_Timesheets.Activity
WHERE (((Month([ActivityDate]))=8) AND ((Year([ActivityDate]))=2018))
GROUP BY tbl_Timesheets.SAP_HRNumber
PIVOT tbl_Activities.Activity;