0

我在表中有不同的字段,例如

来电显示
被叫号码
日期
时间
分钟
收费

在为客户提取账单时,呼叫重叠,如果您指导我如何避免重叠呼叫的 sql 脚本,我将不胜感激。

例如。在一个 Caller_id 似乎同时有两个呼叫,这是不可能的。

CallerId Called_number 日期 时间 分钟 费用
5555555555 42555777777 2013 年 9 月 12 日 17:15:46 44 44
5555555555 5556666666 2013 年 9 月 12 日 17:21:28 5 9.25

提前致谢

4

1 回答 1

1

就像@SimonGoldstone 所说的 CDR 重叠可能有很多原因:

  • 数据由多个没有 NTP 的服务器收集。
  • 每个服务器使用不同的时区。
  • 电话会议

如果您确实想提取包含的调用,可以使用以下代码:

create table t (
Caller_id bigint,
Called_number bigint,
call_date datetime,
duration  float,
charge   float);
insert into t
values 
(5555555555, 42555777777, '2013-12-09 17:15:46', 44, 44),
(5555555555, 5556666666, '2013-12-09 17:21:28', 5,9.25);

select t.*

from t join ( select  caller_id, called_number, call_date as start_date, 
        date_add(call_date,INTERVAL duration minute) as end_date from t) t1 on  (t.caller_id = t1.caller_id and t.call_date between t1.start_date and t1.end_date) where t.called_number != t1.called_number

您还可以查看这篇文章: 重叠日期范围 - 仅识别重叠

于 2013-10-28T12:03:10.187 回答