yjmyzz

要求:

呼叫系统(Call Center)每天会有大量的电话进线数据,领导们要查看每天的进线数汇总,并且要求把 每天从上午8点到上午12点以及下午2点到晚上8点这两个时间段的数据汇总 “视”为当天的数据。--即分组依据
 

思路:把时间段折分成连续二段,一段是从当天08:00到11:59分的数据,一段是当日12:01到19:59分的数据,然后用union all合并起来,最后再用sum求和

代码
select sum(总数) 总数,时间 from (
  
select 
    
count(ID) 总数, 
    to_char(CallDateTime,
\'yyyy-mm-dd\') 时间 
  
from 
    T_Test t 
  
where to_char(CallDateTime,\'hh24\')>=\'08\' and to_char(CallDateTime,\'hh24\')<=\'11\'
  
group by to_char(CallDateTime,\'yyyy-mm-dd\')

  
union all 

  
select 
    
count(ID) 总数, 
    to_char(CallDateTime,
\'yyyy-mm-dd\') 时间 
  
from 
    T_Test t 
  
where to_char(CallDateTime,\'hh24\')>=\'12\' and to_char(CallDateTime,\'hh24\')<=\'19\'
  
group by to_char(CallDateTime,\'yyyy-mm-dd\')
)
group by 时间
order by 时间

 

分类:

技术点:

相关文章:

  • 2021-08-23
  • 2021-11-21
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2021-12-24
  • 2022-02-03
  • 2021-05-20
  • 2022-12-23
  • 2022-03-13
  • 2021-09-30
相关资源
相似解决方案