I have certain tables as follows:
UserID UserName CallDT ResultCode
I am trying to run a query that will show me the total amount of calls for "UserID"
This is what I have done.
The problem is that it doesn't show me the total for an agent. This is what it gives me.
UserID | Total | UserName | CallDT | ResultCode
2005 |2005 |Craig Costello|2010-08-17 | 80
2005 |2005 |Craig Costello|2010-08-17 | 45
2046 |2046 |Joe Servantez| 2010-08-17 | 80
2046 |2046 |Joe Servantez| 2010-08-17 | 71
2046 |2046 |Joe Servantez| 2010-08-17 | 71
2086 |2086 |Vic Day | 2010-08-17 | 85
2086 |2086 |Vic Day | 2010-08-17 | 7
2086 |2086 |Vic Day | 2010-08-17 | 71
What I want to accomplish is the following:
UserID | Total | Username | CallDT | RC80 |RC45|
2005 |---2---| Craig C. | 2010-08-17|---1---|--1-|
So basically UserID who is Username made a total of 2 calls on 2010-08-17 and out of those 2 calls 1 was from ResultCode 80 and the other from ResultCode 45
Could someone please help me with this. I am losing my mind.
Thank you,
UserID UserName CallDT ResultCode
I am trying to run a query that will show me the total amount of calls for "UserID"
This is what I have done.
Code:
SELECT UserID, Sum(CAST(UserID as Int))AS 'Total', UserName, CallDT, ResultCode FROM CallHist WHERE (CallDT BETWEEN '2010-08-17' AND '2010-08-18') AND (NOT (UserID = N'PDIALER')) GROUP BY UserID, UserName, CallDT, ResultCode
UserID | Total | UserName | CallDT | ResultCode
2005 |2005 |Craig Costello|2010-08-17 | 80
2005 |2005 |Craig Costello|2010-08-17 | 45
2046 |2046 |Joe Servantez| 2010-08-17 | 80
2046 |2046 |Joe Servantez| 2010-08-17 | 71
2046 |2046 |Joe Servantez| 2010-08-17 | 71
2086 |2086 |Vic Day | 2010-08-17 | 85
2086 |2086 |Vic Day | 2010-08-17 | 7
2086 |2086 |Vic Day | 2010-08-17 | 71
What I want to accomplish is the following:
UserID | Total | Username | CallDT | RC80 |RC45|
2005 |---2---| Craig C. | 2010-08-17|---1---|--1-|
So basically UserID who is Username made a total of 2 calls on 2010-08-17 and out of those 2 calls 1 was from ResultCode 80 and the other from ResultCode 45
Could someone please help me with this. I am losing my mind.
Thank you,
Comment