鹤壁市长热线,前端git:http://192.168.1.222:3000/clq1010/CallCenter5.0WebUI.git 中的鹤壁12345分支

P_CallInReport.sql 5.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. USE [HBSZRX_20190801]
  2. GO
  3. /******
  4. Object: StoredProcedure [dbo].[P_CallInReport] Script Date: 08/29/2019 15:09:44
  5. 2019-08-29 lihai T_Call_LeaveRecord时间条件修改成F_StartTime(以前是F_DealTime)
  6. ******/
  7. SET ANSI_NULLS ON
  8. GO
  9. SET QUOTED_IDENTIFIER ON
  10. GO
  11. ALTER PROCEDURE [dbo].[P_CallInReport]
  12. @sdate varchar(20),
  13. @edate varchar(20)
  14. AS
  15. BEGIN
  16. create table #tmpCallInReport(时间 VARCHAR(10),电话总呼入量 int,正常接听量 int,语音留言量 int,主动放弃量 int,电话骚扰量 int)
  17. --create table #tmpCallInReport(date VARCHAR(10),totalcount int,answercount int,leavecount int,giveupcount int,harasscount int)
  18. declare @tempdate varchar(10)
  19. declare @temptotalcount int
  20. declare @tempanswercount int
  21. declare @templeavecount int
  22. declare @tempgiveupcount int
  23. declare @tempharasscount int
  24. declare @tempttotalcount int=0
  25. declare @temptanswercount int=0
  26. declare @temptleavecount int=0
  27. declare @temptgiveupcount int=0
  28. declare @temptharasscount int=0
  29. declare @countsum int
  30. declare @count int
  31. --办理临时表
  32. select * INTO #allcallintable FROM T_Call_CallRecords where CallType=0
  33. and datediff(day,BeginTime,@sdate)<=0 and datediff(day,BeginTime,@edate)>=0
  34. set @countsum=DATEDIFF(DAY,@sdate,@edate)+1
  35. select @tempdate=@sdate,@count=0
  36. while @count<@countsum
  37. begin
  38. select * into #daycallintable from #allcallintable where datediff(day,BeginTime,@tempdate)=0
  39. select @temptotalcount=count(1) from #daycallintable
  40. set @tempttotalcount=@tempttotalcount+@temptotalcount
  41. select @tempanswercount=count(1) from #daycallintable where isnull(UserCode,'') !='' and DealType != '1'
  42. set @temptanswercount=@temptanswercount+@tempanswercount
  43. select @templeavecount=count(1) from T_Call_LeaveRecord where datediff(day,F_StartTime,@tempdate)=0
  44. set @temptleavecount=@temptleavecount+@templeavecount
  45. select @tempgiveupcount=count(1)-@templeavecount from #daycallintable where isnull(UserCode,'') ='' and DealType = '0'
  46. set @temptgiveupcount=@temptgiveupcount+@tempgiveupcount
  47. select @tempharasscount=count(1) from #daycallintable where DealType = '1'
  48. set @temptharasscount=@temptharasscount+@tempharasscount
  49. insert into #tmpCallInReport VALUES(@tempdate,@temptotalcount,@tempanswercount,@templeavecount,@tempgiveupcount,@tempharasscount)
  50. set @tempdate=CONVERT(VARCHAR(10), dateadd(DAY,1,@tempdate),120)
  51. set @count=@count+1
  52. DROP TABLE #daycallintable
  53. end
  54. insert into #tmpCallInReport VALUES(N'合计',@tempttotalcount,@temptanswercount,@temptleavecount,@temptgiveupcount,@temptharasscount)
  55. select * from #tmpCallInReport
  56. DROP TABLE #tmpCallInReport
  57. DROP TABLE #allcallintable
  58. END