Sample CDR Database Queries
Topic Last Modified: 2010-12-14
This section contains sample queries for the call detail recording (CDR) database.
Use the following example to get the conference participants organized by a given user and in a specific time range.
declare @Organizer nvarchar(256)
declare @StartTime datetime
declare @EndTime datetime
set @Organizer = 'luka@contoso.com'
set @StartTime = DATEADD(d, -1, getdate())
set @EndTime = GETDATE()
--user join/leave information for signalling
select cu.ConferenceUri, u.UserUri, cv.Version, fjl.UserJoinTime, fjl.UserLeaveTime, r.Role, fjl.IsUserInternal from FocusJoinsAndLeaves fjl
inner join Conferences c on fjl.SessionIdTime = c.SessionIdTime and fjl.SessionIdSeq = c.SessionIdSeq
inner join ConferenceUris cu on c.ConferenceUriId = cu.ConferenceUriId
inner join Users u on u.UserId = fjl.UserId
left join Users org on org.UserId = c.OrganizerId
left join ClientVersions cv on cv.VersionId = fjl.ClientVerId
left join Roles r on r.RoleId = fjl.UserRole
where org.UserUri = @Organizer and fjl.SessionIdTime between @StartTime and @EndTime
--User join/leave information for different conference modalities
select cu.ConferenceUri, ut.UriType, u.UserUri, mjl.UserJoinTime, mjl.UserLeaveTime, mjl.IsFromPstn
from McuJoinsAndLeaves mjl
inner join Conferences c on mjl.SessionIdTime = c.SessionIdTime and mjl.SessionIdSeq = c.SessionIdSeq
inner join ConferenceUris cu on c.ConferenceUriId = cu.ConferenceUriId
inner join Users u on u.UserId = mjl.UserId
left join Users org on org.UserId = c.OrganizerId
left join Mcus m on m.McuId = mjl.McuId
Use the following example to find the total number of public switched telephone network (PSTN) to unified communications (UC) calls:
Select Count(*) as 'Number of PSTN to UC Calls'
From VoipDetails as voipd
Join SessionDetails as sd on (voipd.SessionIdTime = sd.SessionIdTime and voipd.SessionIdSeq = sd.SessionIdSeq and sd.User1Id is null)
and FromNumberId in (SELECT PhoneId from Phones)
and FromGatewayId is not null
Use the following example to find the total numbers of conferences that used Meeting Console:
select COUNT(*) as 'Live Meeting Count' from
(
SELECT distinct c.SessionIdTime, c.SessionIdSeq
from McuJoinsAndLeaves as mj
inner join Mcus m on m.McuId = mj.McuId
inner join Conferences c on c.SessionIdTime = mj.SessionIdTime and c.SessionIdSeq = mj.SessionIdSeq
inner join UriTypes ut on ut.UriTypeId = m.McuTypeId
where ut.UriType= 'conf:data-conf'
) tmp
Use the following example to find the total number of redirected calls:
select COUNT(*) as 'Number of Redirected Calls' from SessionDetails
where ReferredById is not null