Introduction
This document describes some useful queries that can be used in Contact Center Enterprise (CCE) to extract the information.
Prerequisites
Requirements
Cisco recommends that you have knowledge of these topics:
- Cisco Unified Contact Center Enterprise (UCCE) Release 12.6.2
- Cisco Package Contact Center Enterprise (PCCE) Release 12.6.2
- Structured Query Language (SQL)
- Administrative Workstation (AW)
- Administrative Workstation Database (AWDB)
Components Used
The information in this document is based on these software versions:
- PCCE Release 12.6.X
- UCCE Release 12.6.X
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, ensure that you understand the potential impact of any command.
Background
This document covers the basic queries that can be used to exact information from the CCE Database directly using the SQL management studio.
General Queries
Check SQL Version
This query can be used to exact information about SQL Version.
Select @@version
Check SQL System Processes
This query can be used to exact information about SQL processes.
SELECT * FROM sys.SYSPROCESSES
Inbound Queries
The queries covered in this section relates to This tables
- Agent
- Person
- Agent_State_Trace
- Agent_Real_Time
- Campaign
- Termination_Call_Detail
- Route_Call_Detail
Get total Agents
This query can be used to exact information about the agents. It must run on AWDB on the AW.
Select * from Agent
Get total Supervisors
This query can be used to exact information about the Supervisors. It must run on AWDB on the AW.
Select Agent.*,Person.* from Agent inner join Person on Agent.PersonID=Person.PersonID
where SupervisorAgent='Y'
or
SELECT EnterpriseName,SupervisorAgent,FirstName,LastName,LoginName FROM Agent INNER JOIN Person ON Agent.PersonID = Person.PersonID WHERE SupervisorAgent = 'Y'
Get logged in Agents
This query can be used to exact information about the overall agents logged in at a time, It must run on AWDB on the AW.
Select count(A. EnterpriseName) from Agent A, Agent_Real_Time ART where A.SkillTargetID=ART.SkillTargetID and A.PeripheralID= '5000'
and AgentState IN ('4','3','5','6','8')
or
Select A.EnterpriseName from Agent A,Agent_Real_Time ART where A.SkillTargetID=ART.SkillTargetID and A.PeripheralID='5000'
In this query the Peripheral ID is the ID of the agent peripheral gateway
Total count of agents logged in
This query can be used to exact information about the count of agents logged in at a time, It must run on AWDB on the AW.
Select count(A.EnterpriseName) from Agent A,Agent_Real_Time ART where A.SkillTargetID=ART.SkillTargetID and A.PeripheralID='5000'
Check which Agent Team is assigned to Supervisor
This query can be used to exact information about Team assigned to the Supervisor.
SELECT AT.EnterpriseName AS AgentTeam, A.EnterpriseName AS SupervisorName
FROM
Agent_Team AS AT INNER JOIN Agent_Team_Supervisor AS ATS ON AT.AgentTeamID = ATS.AgentTeamID
INNER JOIN Agent AS A ON ATS.SupervisorSkillTargetID = A.SkillTargetID
WHERE A.EnterpriseName LIKE '%Enterprise name of the Supervisor here'
Check which Agent Team is assigned to Agent
This query can be used to exact information about Team assigned to an Agent.
Select A.SkillTargetID , A.EnterpriseName, T.EnterpriseName
from Agent as A ,Agent_Team_Member as ATM, Agent_Team as T
where A.SkillTargetID = ATM.SkillTargetID
and ATM.AgentTeamID = T.AgentTeamID
and A.EnterpriseName like '%Enterprise name of the Agent here'
Information about the total calls handled by the system in a day
This query can be used to exact information about the calls handled in a day.
Select * from Termination_Call_Detail where DateTime>='2025-08-07 00:00:00' and DateTime<='2025-08-07 23:59:59'
Information about a specific call handled in a particular day
This query can be used to exact information about a particular call in a day.
Select * from Termination_Call_Detail where DateTime>='2025-08-07 00:00:00' and DateTime<='2025-08-07 23:59:59' and ANI like'%NUMBER_HERE'
Check where the call ended in the ICM Script
This query can be used to exact information about the point where a particular call ended in the ICM Script, this information must be fetched in two steps.
Step 1
Use This query to get the information like RouterCallKey and RouterCallKeyDay from the Termination_Call_Detail table.
Select DateTime, ANI, RouterCallKey, RouterCallKeyDay from Termination_Call_Detail where DateTime>='2025-08-07 00:00:00' and DateTime<='2025-08-07 23:59:59' and ANI like'%NUMBER_HERE'
Step 2
This join key is be used to get the information where the call ended in the ICM Script using the RouterCallKey and RouterCallKeyDay.
SELECT Master_Script.EnterpriseName, FinalObjectID
FROM Route_Call_Detail
INNER JOIN Script
ON Route_Call_Detail.ScriptID = Script.ScriptID
INNER JOIN Master_Script ON Script.MasterScriptID = Master_Script.MasterScriptID
WHERE RouterCallKeyDay = 'Value of extracted RouterCallKeyDay here'
AND RouterCallKey = 'Value of extracted RouterCallKey here'
Outbound Queries
The queries covered in the section relates to This tables
Total Campaign running in a day
Use This query to get the information about the campaign that ran in a particular day.
Select C.CampaignName,count(DD.CampaignID)CNT
from Dialer_Detail DD, Campaign C
Where DD.DateTime >='2025-08-07 00:00:00'
Where DD.DateTime <='2025-08-07 23:59:59'
and DD.CampaignID=C.CampaignID
Group by DD.CampaignID,C.CampaignName
Order by CNT Desc
Campaign Details for a specific number
Use This query to get the information about a number that in dialed in multiple campaigns in a particular day.
SELECT DateTime,Campaign.CampaignID,Phone,CallResult,Campaign.CampaignName FROM Dialer_Detail
INNER JOIN Campaign ON Dialer_Detail.CampaignID = Campaign.CampaignID
WHERE DateTime >='2025-08-07 00:00:00' and DateTime<='2025-08-07 23:59:59'
AND Phone LIKE '%Number here%'
Campaign Details for a Multiple numbers
Use This query to get the information about multiple numbers that are dialed in multiple campaigns in a particular day.
SELECT Dialer_Detail.DateTime,Dialer_Detail.CampaignID,Phone,CallResult,Campaign.CampaignName FROM Dialer_Detail
INNER JOIN Campaign ON Dialer_Detail.CampaignID = Campaign.CampaignID
WHERE DateTime >='2025-08-07 00:00:00' and DateTime<='2025-08-07 23:59:59'
AND Phone IN ('Number here' , 'Number here' , 'Number here')
Get the list of campaigns where campaign did not run in a month.
Use This query to get the information about the Campaigns that did not run in the last 6 months.
SELECT C.CampaignID, C.CampaignName
FROM Campaign AS C LEFT JOIN
Dialer_Detail AS DD ON C.CampaignID <> DD.CampaignID
WHERE DateTime BETWEEN '2025-07-01 00:00:00' AND '2025-07-31 23:59:59'
GROUP BY C.CampaignID, C.CampaignName
Query For Campaign wise Daily Count
Use This query to get the information about the campaigns run in a day along with the count of dialed attempts against that campaign.
SELECT Cast(DD.DateTime AS date) As Daily,C.CampaignID,C.CampaignName, COUNT(DD.CampaignID) AS CNT
FROM Dialer_Detail DD INNER JOIN Campaign C ON DD.CampaignID = C.CampaignID
WHERE DD.DateTime >='2025-08-07 00:00:00' and DD.DateTime <='2025-08-07 23:59:59'
GROUP BY Cast(DD.DateTime AS date),C.CampaignID,C.CampaignName
ORDER BY CNT DESC
Campaign wise Import Rule Start & End along with Count
Use This query to get the information that covers various details about the campaigns and their imports in a day along with the count of dialed attempts against that campaign.
SELECT IRH.ImportRuleID, IR.ImportRuleName, QR.QueryRuleName, CQR.CampaignID, C.CampaignName, IRH.StartDateTime, IRH.EndDateTime, IRH.TotalRecords
FROM Import_Rule_History AS IRH INNER JOIN
Import_Rule AS IR ON IRH.ImportRuleID = IR.ImportRuleID INNER JOIN
Query_Rule AS QR ON IR.ImportRuleID = QR.ImportRuleID INNER JOIN
Campaign_Query_Rule AS CQR ON QR.QueryRuleID = CQR.QueryRuleID INNER JOIN
Campaign AS C ON CQR.CampaignID = C.CampaignID
WHERE (IRH.StartDateTime BETWEEN '2025-08-07 00:00:00' AND '2025-08-07 23:59:59')