SELECT  F_UserId,F_UserCode,F_UserName,
(SELECT sum(TalkLongTime)  FROM T_Call_CallRecords 
where  UserId=T_Sys_UserAccount.F_Userid 
	and CONVERT(varchar , TalkStartTime, 120)>=CONVERT(varchar , '2018-05-09 00:00:01', 120)
	and CONVERT(varchar , TalkStartTime, 120)<=CONVERT(varchar , '2018-05-09 23:59:59', 120)
) as counts 
from T_Sys_UserAccount order by counts desc

SELECT  *,(SELECT sum(TalkLongTime)  FROM T_Call_CallRecords 
	where  UserId=T_Sys_UserAccount.F_Userid  
	and CONVERT(varchar , TalkStartTime, 120)>=CONVERT(varchar , '2018-04-9 00:00:01', 120)  
	and CONVERT(varchar , TalkStartTime, 120)<=CONVERT(varchar , '2018-5-9 23:59:59', 120) ) as counts 
from T_Sys_UserAccount order by counts desc 

SELECT (SELECT sum(TalkLongTime)  FROM T_Call_CallRecords where  UserId=1418 and CONVERT(varchar , TalkStartTime, 120)>=CONVERT(varchar , '2018-04-9 00:00:01', 120)  and CONVERT(varchar , TalkStartTime, 120)<=CONVERT(varchar , '2018-5-9 23:59:59', 120) ) as sums,(SELECT sum(TalkLongTime) FROM T_Call_CallRecords where  UserId=1418 and CallType=0 and CONVERT(varchar , TalkStartTime, 120)>=CONVERT(varchar , '2018-04-9 00:00:01', 120)  and CONVERT(varchar , TalkStartTime, 120)<=CONVERT(varchar , '2018-5-9 23:59:59', 120) ) as sumshuru,(SELECT sum(TalkLongTime)  FROM T_Call_CallRecords where  UserId=1418 and CallType=1 and CONVERT(varchar , TalkStartTime, 120)>=CONVERT(varchar , '2018-04-9 00:00:01', 120)  and CONVERT(varchar , TalkStartTime, 120)<=CONVERT(varchar , '2018-5-9 23:59:59', 120) ) as sumshuchu


select F_DeptId,F_DeptName,F_Remark from  T_Sys_Department where 1=1 


SELECT CallType,UserId,UserCode,UserName,COUNT(*) AS calloutCount,SUM(TalkLongTime) AS TalkSummaryTime 
FROM T_Call_CallRecords 
where 1=1 
	--and CallType=0  
	and DATEDIFF(d,BeginTime,'2018-05-09')<=0
	and DATEDIFF(d,BeginTime,'2018-05-09')>=0
GROUP BY CallType,UserId,UserCode,UserName