sqlserver呼叫中心保留通话时长最长的记录

sqlserver呼叫中心保留通话时长最长的记录,第1张

概述--在同一天之内,分机号相同,对方号码相同的,呼叫类型为呼出的通话记录,只保留通话时长最长的一条记录--更具Id删除不是通话时长最长的记录 delete from RecordLogInfo where Id in(--找到某段时间范围内,呼叫类型为呼出的不是最长的所有记录 select Id from RecordLogInfo where CtiCallType=1 and LogTi
--在同一天之内,分机号相同,对方号码相同的,呼叫类型为呼出的通话记录,只保留通话时长最长的一条记录--更具ID删除不是通话时长最长的记录
delete from RecordLogInfo where ID in(--找到某段时间范围内,呼叫类型为呼出的不是最长的所有记录
select ID from RecordLogInfo where CtiCallType=1 and LogTime>='2012-10-01' and ID not in (--为了找到通话时长最长的记录,第二步和第一步需要联合查询,找到最长记录的ID
select ID from (--第二步:开始分组,发现分组后ID没有了
select AttendantPhoneNo,UserPhoneNo,LogTime,max(RecordDuration) as RecordDuration,count(*) as counts from (--第一步:找到符合条件的记录
select AttendantPhoneNo,RecordDuration,CONVERT(varchar(10),120) as LogTime from RecordLogInfo where CtiCallType=1 and LogTime>='2012-10-01') RecordLogInfo group by LogTime,AttendantPhoneNo,UserPhoneNo) as a,(select ID,120) as LogTime from RecordLogInfo where CtiCallType=1 and LogTime>='2012-10-01') as b where a.AttendantPhoneNo=b.AttendantPhoneNo and a.UserPhoneNo=b.UserPhoneNo and a.LogTime=b.LogTime and a.RecordDuration=b.RecordDuration) )--如果在拨打过程中按键则系统记录的电话号码的实际长度会增长,截取字段,这样才不会遗漏,最后根据查出来的ID删除数据
select ID from RecordLogInfo where CtiCallType=1 and LogTime>='2012-10-01' and ID not in (select ID from (select AttendantPhoneNo,substring(UserPhoneNo,1,12) as UserPhoneNo,count(*) as counts from (select AttendantPhoneNo,120) as LogTime from RecordLogInfo where CtiCallType=1 and LogTime>='2012-10-01' and len(substring(UserPhoneNo,12))=12) RecordLogInfo group by LogTime,12))=12) as b where a.AttendantPhoneNo=b.AttendantPhoneNo and a.UserPhoneNo=b.UserPhoneNo and a.LogTime=b.LogTime and a.RecordDuration=b.RecordDuration) 
总结

以上是内存溢出为你收集整理的sqlserver呼叫中心保留通话时长最长的记录全部内容,希望文章能够帮你解决sqlserver呼叫中心保留通话时长最长的记录所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/1176944.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存