Query not grouping (1 Viewer)

dbaker5204

Registered User.
Local time
Today, 13:31
Joined
Jan 19, 2018
Messages
20
I have a query that is not grouping by Team. Currently it is grouping by Agent name, Supervisor, Date and it set to group by team, however, it is listing the teams separately. The Teams are linked to a table that lists the queue number and name, and the queue numbers and names are different for each, but shouldn't it still group if the team is the same? SQL is below:


SELECT [HelpDataNew Query].HelpDate, [HelpDataNew Query].AgentName, [HelpDataNew Query].Supervisor, [HelpDataNew Query].Team, Sum([HelpDataNew Query].ACDCalls) AS SumOfACDCalls, Sum([HelpDataNew Query].ACDTime) AS SumOfACDTime, Sum([HelpDataNew Query].ACWTime) AS SumOfACWTime, Sum([HelpDataNew Query].HoldTime) AS SumOfHoldTime, Sum([HelpDataNew Query].ExtInCalls) AS SumOfExtInCalls, Sum([HelpDataNew Query].ExtInTime) AS SumOfExtInTime, Sum([HelpDataNew Query].ExtOutCalls) AS SumOfExtOutCalls, Sum([HelpDataNew Query].ExtOutTime) AS SumOfExtOutTime, Sum([HelpDataNew Query].HeldCalls) AS SumOfHeldCalls, Sum([HelpDataNew Query].TransOutCalls) AS SumOfTransOutCalls, (IIf([ACDCalls]=0,0,([ACDTime]+[ACWTime]+[HoldTime])/[ACDCalls]))/86400 AS AHT2, [HoldTime]/86400 AS HOLDT, [ExtInTime]/86400 AS [InT], [ExtOutTime]/86400 AS OUTT
FROM [HelpDataNew Query]
GROUP BY [HelpDataNew Query].HelpDate, [HelpDataNew Query].AgentName, [HelpDataNew Query].Supervisor, [HelpDataNew Query].Team, (IIf([ACDCalls]=0,0,([ACDTime]+[ACWTime]+[HoldTime])/[ACDCalls]))/86400, [HoldTime]/86400, [ExtInTime]/86400, [ExtOutTime]/86400
HAVING (((Sum([HelpDataNew Query].ACDCalls))>0));
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:31
Joined
May 7, 2009
Messages
19,237
rearrange your Group By and put Team as the first in the list, then supervisor, agentname, date, etc.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:31
Joined
Feb 19, 2013
Messages
16,608
shouldn't it still group if the team is the same?
only if all the other fields are the same as well. If you look at the result, you will probably find you have different values in helpdate or most likely agentname, etc.

Remove these columns and you will get the result required -
 

plog

Banishment Pending
Local time
Today, 15:31
Joined
May 11, 2011
Messages
11,646
I'm only trying to be half a shit-head with this - It groups by everything in the GROUP BY.

So, every unique permutation of the items in the GROUP BY will appear in their own record. Which means for every unique value in this calculation:

(IIf([ACDCalls]=0,0,([ACDTime]+[ACWTime]+[HoldTime])/[ACDCalls]))/86400, [HoldTime]/86400, [ExtInTime]/86400, [ExtOutTime]/86400

Will be in its own record. Did you intend to GROUP BY that calculation?
 

Users who are viewing this thread

Top Bottom