SQL server 按小时统计一天的数据
来源:互联网 发布:利安达事务所 知乎 编辑:程序博客网 时间:2024/04/29 20:07
select right(100+a,2)+ ' -- '+right(100+b,2)+ ' ' as DtTime,
sum( case when datepart(hour,DtTime)> =a and datepart(hour,DtTime) <b then 1 else 0 end ) as [Count]
from DtRecords c , (select 0 a,1 b union all select 1,2 union all select 2,3 union all select 3,4 union all select 4,5 union all select 5,6 union all select 6,7 union all select 7,8 union all select 8,9 union all select 9,10 union all select 10,11 union all select 11,12 union all select 12,13 union all select 13,14 union all select 14,15 union all select 15,16 union all select 16,17 union all select 17,18 union all select 18,19 union all select 19,20 union all select 20,21 union all select 21,22 union all select 22,23 union all select 23,24 ) aa
where datediff(day, '2016-12-09', DtTime) = 0 and InOut = '1' group by right(100 + a, 2) + ' -- ' + right(100 + b, 2) + ' ' order by DtTime asc
sum( case when datepart(hour,DtTime)> =a and datepart(hour,DtTime) <b then 1 else 0 end ) as [Count]
from DtRecords c , (select 0 a,1 b union all select 1,2 union all select 2,3 union all select 3,4 union all select 4,5 union all select 5,6 union all select 6,7 union all select 7,8 union all select 8,9 union all select 9,10 union all select 10,11 union all select 11,12 union all select 12,13 union all select 13,14 union all select 14,15 union all select 15,16 union all select 16,17 union all select 17,18 union all select 18,19 union all select 19,20 union all select 20,21 union all select 21,22 union all select 22,23 union all select 23,24 ) aa
where datediff(day, '2016-12-09', DtTime) = 0 and InOut = '1' group by right(100 + a, 2) + ' -- ' + right(100 + b, 2) + ' ' order by DtTime asc
0 0
- SQL server 按小时统计一天的数据
- SQL Server如何统计每两小时的值
- 如何统计一天24小时每个小时的数据量
- sql语句 按小时统计
- sql按小时统计信息量
- solr按小时抽取一天数据
- sql server数据分组统计
- elastic按小时统计当天数据
- 报表统计,MySQL,统计:时间段内一天中每隔两小时统计的数量
- SQL SERVER 统计一段时间内每天的数据
- [ASP.NET] SQL SERVER 统计一天24小内的交易量 编辑:吴立星
- PL/SQL 按小时间隔生成一年的时间数据
- oracle的sql:24小时一天分成12个时段
- sql语句 用户一天的数据,取最大的一条,再统计
- 补全或生成一个一天24小时的数据
- sqlserver获取一段时间内每一天每一小时的数据
- Mysql 查询一天中,每个小时数据的数量
- SQL SERVER的统计信息
- Spring MVC Controller单例陷阱
- String和charter类的常用方法
- Linux 操作命令(有关文件)
- (python)Fiddler+工具
- Papers read
- SQL server 按小时统计一天的数据
- jenkins 分布式部署项目
- c++中try catch的用法
- 非负矩阵分解及在量化中的作用探索
- Struts2.5自定义struts.xml文件的位置和文件名
- 草根程序员进入BAT
- 第十六周项目—学生信息排序
- Swift UITableView 插入及自动滚动到底部
- nginx缓存引发的问题