我想从下面的数据表中找出重复调用。任何电话 当一个人再次呼叫同一个问题时,可以算作重复(Call_Outcome)。
UCID Phone_Number Call_Time Call_Outcome Call_ID Skill_Name
121312 01819202020 11:11 Balance 1231 Corporate
121310 01819202020 11:11 Call drop 1231 Corporate
413921 01819202020 01:21 balance 3212 corporate
213412 01819202020 01:32 Call drop 2312 corporate
213412 01819202020 01:32 Goon goon 2312 corporate
987654 01823898989 04:12 Gprs 2345 IR
434323 01823898989 05:12 Gprs 2131 IR
213143 01819202020 06:23 Goon 5676 corporate
213143 01819202020 06:23 balance 5676 corporate
结果应如下所示
SkillName Ans Repeat
Cor 4 3
IR 2 1
我尝试了以下查询,但它没有给出确切的结果。
select left(Skill_Name,3)as SkillName, count(call_Id) as Ans,
count(UCID) as RepeatCall
from(select UCID, Phone_Number, Skill_Name, Call_Outcome, count(Call_Outcome)-1 as cqc
from cdr where UCID IN (SELECT A.UCID FROM cdr A INNER JOIN (SELECT Phone_Number, Call_Outcome
FROM cdr GROUP BY Phone_Number, Call_Outcome HAVING COUNT(*) > 1) B ON A.Phone_Number = B.Phone_Number AND A.Call_Outcome = B.Call_Outcome
ORDER BY `A`.`Phone_Number`)
group by Phone_Number, Call_Outcome)As rep
where cqc<>0 group by SkillName;