3

我正在编写一些 SQL 代码来查询 Lync LCSCDR 数据库。

如果有人从外部呼叫响应组而另一个响应组,则记录将进入sessionDetails表(和Voipdetails表) - 以反映所做的呼叫。

但是,似乎无法确定谁接听了电话。该user2id列填充了响应组的userid(来自Users表格)而不是接听电话的人。有谁知道是否有办法猜测谁接听了电话?

查询是:

SELECT 
    sd.SessionIdTime, 
    sd.SessionEndTime,
    DATEDIFF(
        ss, 
        sd.SessionIdTime, 
        ISNULL(sd.SessionEndTime, sd.SessionIdTime)
    ) AS duration,
    ph1.PhoneUri AS caller1,
    ph2.PhoneUri AS receiver1, 
    U1.UserUri AS user1uri, 
    U2.UserUri AS user2uri, 
    U3.UserUri AS refeereruri, 
    sd.User1Id, 
    sd.User2Id,
    sd.ReferredById,
    sd.IsUser1Internal, 
    sd.IsUser2Internal,
    sd.SessionIdTime, 
    voipd.*, 
    '|||',
    sd.*
FROM 
    dbo.VoipDetails AS voipd 
INNER Join 
    dbo.SessionDetails AS sd 
ON 
    (
        voipd.SessionIdTime = sd.SessionIdTime AND 
        voipd.SessionIdSeq = sd.SessionIdSeq
    ) 
LEFT OUTER JOIN 
    dbo.Users AS U2 -- still 4795 with outer
ON 
    U2.UserId = sd.User2Id
LEFT OUTER JOIN 
    dbo.Users AS U1
ON 
    U1.UserId = sd.User1Id 
LEFT OUTER JOIN 
    dbo.Users AS U3
ON 
    U3.UserId = sd.ReferredById
LEFT OUTER JOIN 
    dbo.Phones AS ph1
ON 
    ph1.PhoneId = voipd.FromNumberId
LEFT OUTER JOIN 
    dbo.Phones AS ph2
ON 
    ph2.PhoneId = voipd.ConnectedNumberId
WHERE 
    sd.SessionIdTime > (GETDATE() - 2) 
    AND sd.MediaTypes = 16 
    AND voipd.FromGatewayId  is not null -- external
    AND User1Id IS NULL
4

1 回答 1

0

有一种方法可以找到您的问题的答案,但您需要第二个应用程序才能做到这一点

当调用 RG 时,调用将填充 CorrelationID

对于填充 CorrelationID 的每一行,您必须搜索没有 CorrelationID 的行,其中 RefferdByID 是被调用的 RG。大多数情况下,应答用户将成为呼叫者,而被呼叫者是具有 CorrelationID 的线路的呼叫者

于 2015-11-26T09:30:38.957 回答