Skip to content

Instantly share code, notes, and snippets.

@fasteddys
Forked from iamric/CCSQL
Created August 13, 2022 17:43
Show Gist options
  • Save fasteddys/e492c0aa61e41a6cc742a2520d2712dc to your computer and use it in GitHub Desktop.
Save fasteddys/e492c0aa61e41a6cc742a2520d2712dc to your computer and use it in GitHub Desktop.
Call Center SQL
SELECT usercode, count(CAST(usercode AS int)) AS Total
FROM disposition with (nolock)
where disposition in ('SF', 'SR', 'SC')
GROUP BY usercode
SELECT enterpriseagentid as Agent, CONVERT(varchar, callstart, 101) AS Date, count(*) AS Minutes
FROM dbo.disposition with (nolock)
WHERE (usercode IN (20, 30, 31, 32, 33, 38, 50)) AND (callstart > '11/30/08')
GROUP BY CONVERT(varchar, callstart, 101), enterpriseagentid
ORDER BY CONVERT(varchar, callstart, 101)
DECLARE @calldate AS smalldatetime DECLARE @begindate AS smalldatetime
SET @calldate = CONVERT(varchar, GETDATE(), 101)
SET @begindate = CONVERT(varchar, DateAdd(day, - (day(getdate()) - 1), getdate()), 101)
SELECT dateadd(dd, datediff(dd, 0, callstart), 0), count(cast(usercode as int))
FROM dbo.disposition
WHERE callstart BETWEEN @begindate AND @calldate AND usercode IN (20, 30, 31, 32, 33, 38, 50)
GROUP BY dateadd(dd, DATEDIFF(dd, 0, callstart), 0)
ORDER BY dateadd(dd, DATEDIFF(dd, 0, callstart), 0)
SELECT agentactivityid, stationid, enterpriseagentid, login, logout, totaltime, talktime, waittime, idletime, closetime, canceltime, cancelcount, active
FROM dbo.agentactivity
WHERE (agentactivityid IN
(SELECT agentactivityid
FROM dbo.agentactivityDetail
WHERE (enterpriseagentid = '22962') AND (project = 'voicenet_gor200')))
SELECT convert(varchar, callstart, 101), usercode, count(CAST(usercode AS int)) AS Total
FROM disposition with (nolock)
where disposition in ('SF', 'SR', 'SC') and callstart >= '12/01/2008'
GROUP BY convert(varchar, callstart, 101), usercode
order by usercode, convert(varchar, callstart, 101)
SELECT *
FROM result
where q150 = '1' and disposition <> 'SC'
select *
from disposition l left outer join result r on l.enterpriselistid = r.enterpriselistid
where l.class = 'C' and r.disposition <> 'SC'
select *
from disposition
where enterpriselistid = 3804297 order by callstart
select *
from list
where enterpriselistid = 3804297
SELECT *
FROM result
where disposition = 'SC'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment