Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Multi-part Identifier Could not be bound

Author  Topic 

jawad.hassan
Starting Member

6 Posts

Posted - 2012-07-23 : 03:54:35
Hi,

I am using below query to report agent performance but getting error

The multi-part identifier "TCD.AgentSkillTargetID" could not be bound.


Query:

SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, ASGI.DateTime)) AS Date, P.PersonID, A.SkillTargetID, Result.AgentIdleTime,
P.FirstName + ' ' + P.LastName AS AgentName, A.PeripheralName as LoginName, ASGI.SkillGroupSkillTargetID, SG.EnterpriseName, Result.LoggedIn As LoggedIn, Result.NotReady,
SUM(ASGI.HandledCallsTalkTime) AS TalkTime, SUM(ASGI.AbandonRingTime) AS RingTime,
SUM((IncomingCallsOnHoldTime + InternalCallsOnHoldTime) - (AutoOutCallsOnHoldTime + PreviewCallsOnHoldTime + ReserveCallsOnHoldTime)) AS HoldTime,
SUM(ASGI.CallsHandled) AS CallsPresented, SUM(ASGI.CallsAnswered) AS CallsAnswered,
SUM(ASGI.AbandonRingCalls) AS AbandonCalls, SUM(ASGI.ShortCalls) AS ShortCalls, SUM(ASGI.TransferredInCalls) AS Transferred, SUM(ASGI.TransferredOutCalls) AS MissedCalls

FROM Person AS P INNER JOIN
Agent AS A ON P.PersonID = A.PersonID INNER JOIN
Agent_Skill_Group_Interval AS ASGI ON A.SkillTargetID = ASGI.SkillTargetID INNER JOIN
Skill_Group AS SG ON ASGI.SkillGroupSkillTargetID = SG.SkillTargetID INNER JOIN

(SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, DateTime)) AS Date, SkillGroupSkillTargetID, SkillTargetID, SUM(LoggedOnTime) AS LoggedIn,
SUM(NotReadyTime) AS NotReady,SUM(AvailTime) AS AgentIdleTime
FROM Agent_Skill_Group_Interval
WHERE (DateTime BETWEEN DATEADD(hour, CONVERT(INT, 0),DATEADD(minute, CONVERT(INT, 0), '2012-07-20')) AND DATEADD(hour,CONVERT(INT, 23), DATEADD(minute, CONVERT(INT, 59), '2012-07-20'))) --AND (SkillTargetID IN (5052))
AND (SkillGroupSkillTargetID = 5000)
GROUP BY SkillGroupSkillTargetID, SkillTargetID, DATEADD(dd, 0, DATEDIFF(dd, 0, DateTime))) AS Result ON
Result.SkillTargetID = ASGI.SkillTargetID AND Result.Date = DATEADD(dd, 0, DATEDIFF(dd, 0, ASGI.DateTime)) INNER JOIN

(SELECT TCD.AgentSkillTargetID, COUNT(TCD.AgentSkillTargetID) AS Hangup

FROM ptcl_custom.dbo.CDR AS CDR LEFT OUTER JOIN

Termination_Call_Detail AS TCD ON CDR.PeripheralCallKey = TCD.PeripheralCallKey

WHERE (TCD.DateTime BETWEEN DATEADD(hour, CONVERT(INT, 10),DATEADD(minute, CONVERT(INT, 0), '2012-07-20'))

AND DATEADD(hour,CONVERT(INT, 11), DATEADD(minute, CONVERT(INT, 0),'2012-07-20')))
--AND (TCD.AgentSkillTargetID IN (5398))

AND destCause_value = 16

GROUP BY TCD.AgentSkillTargetID) AS Hang ON TCD.AgentSkillTargetID = A.SkillTargetID

WHERE (ASGI.DateTime BETWEEN DATEADD(hour, CONVERT(INT, 0),DATEADD(minute, CONVERT(INT, 0), '2012-07-20')) AND DATEADD(hour, CONVERT(INT, 23), DATEADD(minute, CONVERT(INT, 59), '2012-07-20'))) AND (ASGI.SkillGroupSkillTargetID NOT IN (5000)) --AND (A.SkillTargetID IN (5052)) AND (ASGI.SkillGroupSkillTargetID IN (5013))

GROUP BY P.PersonID, A.SkillTargetID, P.FirstName, P.LastName,A.PeripheralName , ASGI.SkillGroupSkillTargetID, SG.EnterpriseName,
DATEADD(dd, 0, DATEDIFF(dd, 0, ASGI.DateTime)), Result.LoggedIn, Result.NotReady,Result.AgentIdleTime

ORDER BY P.PersonID ASC

Please reply me. It's urgent

Regards,


Jawad Hassan

Rimsky
Starting Member

12 Posts

Posted - 2012-07-23 : 06:39:08
It looks like there's a bracket missing in this part:
(SELECT TCD.AgentSkillTargetID, COUNT(TCD.AgentSkillTargetID) AS Hangup
FROM ptcl_custom.dbo.CDR AS CDR LEFT OUTER JOIN
Termination_Call_Detail AS TCD ON CDR.PeripheralCallKey = TCD.PeripheralCallKey
WHERE (TCD.DateTime BETWEEN DATEADD(hour, CONVERT(INT, 10),DATEADD(minute, CONVERT(INT, 0), '2012-07-20'))
AND DATEADD(hour,CONVERT(INT, 11), DATEADD(minute, CONVERT(INT, 0),'2012-07-20')))
--AND (TCD.AgentSkillTargetID IN (5398))
Go to Top of Page
   

- Advertisement -