如何将记录按操作时间的小时group by

bingbhz 2004-09-08 12:01:55
需要统计一段时间内每个时段(小时)内的记录数,请教。
...全文
274 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zlj113 2004-09-08
  • 打赏
  • 举报
回复
取出小时为:datename(hour,you_time)
lsxaa 2004-09-08
  • 打赏
  • 举报
回复
select datepart(hour,时间字段) as 小时,count(*) 记录数
from 表
where 时间字段>=日期1 and 时间字段<=日期2
group by datepart(hour,时间字段) order by 小时
yesterday2000 2004-09-08
  • 打赏
  • 举报
回复
select count( Datepart(hour,日期)) as j from docdsp group by Datepart(hour,日期)
zicxc 2004-09-08
  • 打赏
  • 举报
回复
datepart(hour,操作时间)
不同天的合在一起,看你的应用了
WangZWang 2004-09-08
  • 打赏
  • 举报
回复
如:
select count(1),datepart(hour,时间字段) from 表名
group by datepart(hour,时间字段)
zheninchangjiang 2004-09-08
  • 打赏
  • 举报
回复
select datediff(hour,@datebegin,datecolumn) as dhour,sum(...) from [table]
where datecolumn between @datebegin and @dateend group by datediff(hour,@datebegin,datecolumn)
leeboyan 2004-09-08
  • 打赏
  • 举报
回复
select count(1) from t where ... group by datepart(hour,时间字段)
zicxc 2004-09-08
  • 打赏
  • 举报
回复
select convert(char(13),日期,120) as 小时,
count(*) as 记录数
from 你的表
where 日期 between 日期1 and 日期2
group by convert(char(13),日期,120)
pbsql 2004-09-08
  • 打赏
  • 举报
回复
group by datepart(hour,操作时间)
leeboyan 2004-09-08
  • 打赏
  • 举报
回复
group by datepart(hour,时间字段)

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧