码迷,mamicode.com
首页 > 其他好文 > 详细

查下昨天下午4点到现在 青岛3000占总3000的处理比例

时间:2019-10-05 16:22:52      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:col   tween   between   creat   family   like   roman   天下   font   

 

 

 
 
查下昨天下午4点到现在 青岛3000占总3000的处理比例
 
select count (*) from do_log with(nolock ) where createtime between ‘20151012 16:00:000‘ and ‘20151013 13:00:000‘  and  ( driverId like ‘132-%‘ or driverId like ‘133-%‘ )
select count (*)  from do_log with(nolock ) where createtime between ‘20151012 16:00:000‘ and ‘20151013 13:00:000‘  and ( driverId like ‘132-%‘ or driverId like ‘133-%‘ or driverId like ‘120-%‘or driverId like ‘121-%‘or driverId like ‘122-%‘or driverId like ‘129-%‘ or driverId like ‘130-%‘or driverId like ‘131-%‘or driverId like ‘128-%‘or driverId like ‘124-%‘or driverId like ‘125-%‘ )
select 14899.0/ 33501
 
select cast (sum( case when left(driverid ,4) in(‘132-‘ ,‘133-‘) then 1 else 0 end )*100.0/ count(*) as decimal (10, 2)) ‘百分比‘ ,count(*) ‘总笔数‘  from do_log with( nolock) where createtime between ‘20151012 16:00:000‘ and ‘20151013 13:00:000‘   and ( driverId like ‘132-%‘ or driverId like ‘133-%‘ or driverId like ‘120-%‘or driverId like ‘121-%‘or driverId like ‘122-%‘or driverId like ‘129-%‘ or driverId like ‘130-%‘or driverId like ‘131-%‘or driverId like ‘128-%‘ or driverId like ‘124-%‘or driverId like ‘125-%‘ )
 
select cast (sum( case when left(driverid ,4) in(‘132-‘ ,‘133-‘) then 1 else 0 end )*100.0/ count(*) as decimal (10, 2)) ‘百分比‘ ,count(*) ‘总笔数‘  from do_log with( nolock) where createtime between ‘20151012 16:00:000‘ and ‘20151013 13:00:000‘ and callerid=3000
  
 
 
 
 
再统计下每个小时的占比
 
 select  convert(varchar (13), createtime,20 ) ‘时间‘ ,cast( sum(case when left(driverid, 4) in(‘132-‘, ‘133-‘) then 1 else 0 end )*100.0/ count(*) as decimal (10, 2)) ‘百分比‘,count (*) ‘总笔数‘ from do_log with (nolock) where createtime between ‘20151012 16:00:000‘ and ‘20151013 13:00:000‘ and callerid=3000 group by convert(varchar (13), createtime,20 )
 order by convert (varchar( 13),createtime ,20)
 
 select convert(varchar (13), createtime,20 ) ‘时间‘ ,cast( sum(case when left(driverid, 4) in(‘132-‘, ‘133-‘) then 1 else 0 end )*100.0/ count(*) as decimal (10, 2)) ‘百分比‘,count (*) ‘总笔数‘   from do_log with (nolock) where createtime between ‘20151012 16:00:000‘ and ‘20151013 13:00:000‘   and ( driverId like ‘132-%‘ or driverId like ‘133-%‘or driverId like ‘120-%‘or driverId like ‘121-%‘ or driverId like ‘122-%‘or driverId like ‘129-%‘or driverId like ‘130-%‘ or driverId like ‘131-%‘or driverId like ‘128-%‘or driverId like ‘124-%‘ or driverId like ‘125-%‘ )
group by convert( varchar(13 ),createtime, 20)  order by convert( varchar(13 ),createtime, 20)

查下昨天下午4点到现在 青岛3000占总3000的处理比例

标签:col   tween   between   creat   family   like   roman   天下   font   

原文地址:https://www.cnblogs.com/ComputerVip/p/11624711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!