SELECT UserId,UserCode,UserName,COUNT(*) AS 总量, (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallState=1 and UserCode=t.UserCode ) 接通量, (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=0 and UserCode=t.UserCode) 呼入量, (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=0 and CallState=1 and UserCode=t.UserCode ) 呼入接通量, (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=0 and CallState=0 and UserCode=t.UserCode ) 呼入未接通量, (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=1 and UserCode=t.UserCode) 呼出量, (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=1 and CallState=1 and UserCode=t.UserCode ) 呼出接通量, (SELECT COUNT(*) FROM T_Call_CallRecords where 1=1 and CallType=1 and CallState=0 and UserCode=t.UserCode ) 呼出未接通量 FROM T_Call_CallRecords t where 1=1 --and CallType=0 --and CallState=0 and DealType<>1 GROUP BY UserId,UserCode,UserName