请教一个按时间查询问题!

xyuncn 2003-07-23 03:52:03
表的形式为
id starttm
1 2003-07-15 11:27:53
2 2003-07-15 11:27:53
3 2003-07-15 11:27:53
4 2003-07-15 11:27:54
5 2003-07-15 11:27:55
6 2003-07-15 11:27:56
7 2003-07-15 11:27:56
8 2003-07-15 11:27:57
...........................

需要按时间进行抽样统计,譬如抽样时间间隔为3秒,统计结果为
tm count1
2003-07-15 11:27:53 3
2003-07-15 11:27:56 2
.............................

该如何用sql语句实现?
thanks!
...全文
59 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
friendliu 2003-07-23
  • 打赏
  • 举报
回复
decalre @aa int
select @int='3'

select startttm tm,count(starttm) count1
where datediff(second,(select min(startm) from table1),starttm)%3=0

group by starttm
friendliu 2003-07-23
  • 打赏
  • 举报
回复
decalre @aa int
select @int='3'

select startttm,count(starttm)
where datediff(second,'2003-07-15 11:27:53',starttm)='3'

group by starttm
playyuer 2003-07-23
  • 打赏
  • 举报
回复
group by datediff(second,'2003-07-15 11:27:53','2003-07-15 11:27:00')/3
愉快的登山者 2003-07-23
  • 打赏
  • 举报
回复
select starttm tm, count(*) countl from table1
where datediff(ss, (select min(startm) from table1), starttm) % 3 = 0
group by starttm

34,590

社区成员

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

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