平顶山新华区民意调查项目API

sql_20180517_通话量.sql 959B

1234567891011121314
  1. SELECT UserId,UserCode,UserName,COUNT(*) AS 总量,
  2. (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallState=1 and UserCode=t.UserCode ) 接通量,
  3. (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=0 and UserCode=t.UserCode) 呼入量,
  4. (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=0 and CallState=1 and UserCode=t.UserCode ) 呼入接通量,
  5. (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=0 and CallState=0 and UserCode=t.UserCode ) 呼入未接通量,
  6. (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=1 and UserCode=t.UserCode) 呼出量,
  7. (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=1 and CallState=1 and UserCode=t.UserCode ) 呼出接通量,
  8. (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=1 and CallState=0 and UserCode=t.UserCode ) 呼出未接通量
  9. FROM T_Call_CallRecords t
  10. where 1=1
  11. --and CallType=0
  12. --and CallState=0
  13. and DealType<>1
  14. GROUP BY UserId,UserCode,UserName