I have a query pulling from two queries. I have to be able to pull all the active employee names from the first query and even if they do not have any data for that day in the second query. My query works fine until I add a date parameter that is directed at the second query. When i tell it to pull all the reps data between certain dates I then lose the reps that didn't have data between those dates. If I don't use the parameter all the names come back. I believe this has something to do with the fact that the 1st query is just a list of names with no date field so I have to use the second query to be able to use a date parameter. How can I get around this? Here is the SQL for the query:
SELECT [Active Employee Information Query].Department, [Active Employee Information Query].[Employee First Name], [Active Employee Information Query].[Employee Last Name], Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![CallsOffered]),0,[AgentPerformanceTable_All_Totals]![CallsOffered])) AS CallsOffered, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![CallsAnswered]),0,[AgentPerformanceTable_All_Totals]![CallsAnswered])) AS CallsAnswered, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![NotReadyTime]),0,[AgentPerformanceTable_All_Totals]![NotReadyTime])) AS NotReadyTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![LoggedInTime]),0,[AgentPerformanceTable_All_Totals]![LoggedInTime])) AS LoggedInTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![RingTime]),0,[AgentPerformanceTable_All_Totals]![RingTime])) AS RingTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![AvgRingTime]),0,[AgentPerformanceTable_All_Totals]![AvgRingTime])) AS AvgRingTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![TalkTime]),0,[AgentPerformanceTable_All_Totals]![TalkTime])) AS TalkTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![AvgTalkTime]),0,[AgentPerformanceTable_All_Totals]![AvgTalkTime])) AS AvgTalkTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![HoldTime]),0,[AgentPerformanceTable_All_Totals]![HoldTime])) AS HoldTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![ExternalCalls]),0,[AgentPerformanceTable_All_Totals]![ExternalCalls])) AS ExternalCalls
FROM [Active Employee Information Query] LEFT JOIN AgentPerformanceQueryStep1 ON ([Active Employee Information Query].[Employee Last Name] = AgentPerformanceQueryStep1.AgentLastName) AND ([Active Employee Information Query].[Employee First Name] = AgentPerformanceQueryStep1.AgentFirstName)
WHERE ((([Active Employee Information Query].Department)="Member Services" Or ([Active Employee Information Query].Department)="Physician Relations" Or ([Active Employee Information Query].Department)="Team Lead" Or ([Active Employee Information Query].Department)="Trainer" Or ([Active Employee Information Query].Department)="Management") AND ((AgentPerformanceQueryStep1.DateStamp) Between [Start Date] And [End Date]))
GROUP BY [Active Employee Information Query].Department, [Active Employee Information Query].[Employee First Name], [Active Employee Information Query].[Employee Last Name];
I hope someone can help!
SELECT [Active Employee Information Query].Department, [Active Employee Information Query].[Employee First Name], [Active Employee Information Query].[Employee Last Name], Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![CallsOffered]),0,[AgentPerformanceTable_All_Totals]![CallsOffered])) AS CallsOffered, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![CallsAnswered]),0,[AgentPerformanceTable_All_Totals]![CallsAnswered])) AS CallsAnswered, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![NotReadyTime]),0,[AgentPerformanceTable_All_Totals]![NotReadyTime])) AS NotReadyTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![LoggedInTime]),0,[AgentPerformanceTable_All_Totals]![LoggedInTime])) AS LoggedInTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![RingTime]),0,[AgentPerformanceTable_All_Totals]![RingTime])) AS RingTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![AvgRingTime]),0,[AgentPerformanceTable_All_Totals]![AvgRingTime])) AS AvgRingTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![TalkTime]),0,[AgentPerformanceTable_All_Totals]![TalkTime])) AS TalkTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![AvgTalkTime]),0,[AgentPerformanceTable_All_Totals]![AvgTalkTime])) AS AvgTalkTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![HoldTime]),0,[AgentPerformanceTable_All_Totals]![HoldTime])) AS HoldTime, Sum(IIf(IsNull([AgentPerformanceTable_All_Totals]![ExternalCalls]),0,[AgentPerformanceTable_All_Totals]![ExternalCalls])) AS ExternalCalls
FROM [Active Employee Information Query] LEFT JOIN AgentPerformanceQueryStep1 ON ([Active Employee Information Query].[Employee Last Name] = AgentPerformanceQueryStep1.AgentLastName) AND ([Active Employee Information Query].[Employee First Name] = AgentPerformanceQueryStep1.AgentFirstName)
WHERE ((([Active Employee Information Query].Department)="Member Services" Or ([Active Employee Information Query].Department)="Physician Relations" Or ([Active Employee Information Query].Department)="Team Lead" Or ([Active Employee Information Query].Department)="Trainer" Or ([Active Employee Information Query].Department)="Management") AND ((AgentPerformanceQueryStep1.DateStamp) Between [Start Date] And [End Date]))
GROUP BY [Active Employee Information Query].Department, [Active Employee Information Query].[Employee First Name], [Active Employee Information Query].[Employee Last Name];
I hope someone can help!