MYSQL时间间隔及按时间间隔求和数据
我有一个表,它将根据一分钟的间隔记录所有数据。现在我想检索记录,如果给定的时间间隔为 2 分钟,则应添加间隔为 2 分钟的完整记录并显示在屏幕上。 假设表是:
日期 |时间 |数据
2011年11月20日| 9:00 | 2
2011年11月20日| 9:01 | 3
2011年11月20日| 9:02 | 6
2011年11月20日| 9:03 | 9:03 2
2011年11月20日| 9:04 | 9:04 1
2011年11月20日| 9:05 | 9:05 4
2011年11月20日| 9:06 | 9:06 4
因此,如果开始日期选择为 20-11-2011,开始时间为 9:01,间隔为 2 分钟,则该表应为:
日期 |时间 |数据
2011年11月20日| 9:01 | 9
2011年11月20日| 9:03 | 9:03 3
2011年11月20日| 9:05 | 9:05 8
请帮我解决这个问题,我是 mysql 和 php 的新手
:时间是时间戳类型..
I have a table which will log all the data based on one minute interval. Now I want to retrieve the records such that, if the time interval is given 2 minutes it should add the complete records with 2 minutes interval and show on screen..
Suppose the Table is:
Date | Time | Data
20-11-2011| 9:00 | 2
20-11-2011| 9:01 | 3
20-11-2011| 9:02 | 6
20-11-2011| 9:03 | 2
20-11-2011| 9:04 | 1
20-11-2011| 9:05 | 4
20-11-2011| 9:06 | 4
So, if the start date is selected as 20-11-2011 and start time as 9:01 and interval as 2 minutes, then the table should be:
Date | Time | Data
20-11-2011| 9:01 | 9
20-11-2011| 9:03 | 3
20-11-2011| 9:05 | 8
Kindly help me with this, I'm new to mysql and php
Here: Time is a Timestamp type..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该有效:
This should work: