Advertisement

mysql group by count as case when

阅读量:
复制代码
 select count(extension_num) as callAll,sum(talk_length) as talkLength,

    
 count(case when call_type=1 then 1 else null end) as callin,
    
 count(case when call_type=0 then 1 else null end) as callout,
    
 COUNT(case when call_type=0 and talk_length>0 then 1 else null end) as calloutYes,
    
 COUNT(case when call_type=0 and talk_length=0 then 1 else null end) as calloutNo,
    
 COUNT(case when call_type=1 and talk_length=0 then 1 else null end) as callinNo,
    
 COUNT(case when call_type=1 and talk_length>0 then 1 else null end) as callInYes,
    
 extension_num from t_call_call

全部评论 (0)

还没有任何评论哟~