整个日期的 SQL 差异
我正在尝试设计一个按日期对记录进行分组的查询。我有代表已发生事件的记录。如果事件发生在同一部分并且彼此间隔在 50 毫秒内,则应将它们分组。我的表格的重要部分如下所示:
ID | sectionID | eventDateTime | ...
我想我想按 sectionID
和 eventDateTime
进行分组(sectionID
将跨越 ID)并使用having子句来定义我的时间分组约束。我还认为这对于查询来说可能是不可能的。我看到了 DATEDIFF()
,但它只对日期的单个组成部分进行计算。任何帮助将不胜感激。
I am trying to devise a query that will group records by date. I have records that represent events that have occurred. If events occurred on the same section and within 50ms of each other, they should be grouped. The important part of my table looks like this:
ID | sectionID | eventDateTime | ...
I am thinking I would want to group by sectionID
and eventDateTime
(a sectionID
will span IDs) and use a having clause to define my time grouping constraints. I also think this might not be possible with a query. I saw DATEDIFF()
, but that only does calculations on a single component of the dates. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否正在寻找类似于以下内容的东西:
Are you looking for something akin to the following: