如何从我的表中分组冲突事件

编程入门 行业动态 更新时间:2024-10-13 10:22:44
本文介绍了如何从我的表中分组冲突事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个带有fiels的事件表:

I have an event table with fiels :

[id], [name], [from_date], [to_date]

我想要 GROUP 冲突事件(事件持续时间相同。如果是事件发生在2013年1月1日和2013年2月1日。我想将此事件与同时发生的其他事件分组)和 DROP 事件不是''相互冲突。我希望输出为日期,没有输出中未列出的冲突。我想识别每个组,这就是我添加 [group_no] 的原因。我怎样才能在SQL Server中 group ?

I want to GROUP conflicting events(Events coming in same duration .if an event happening in date from 1/1/2013 and 2/1/2013.I want to group this event withother events happening in the same time) and DROP events that aren''t conflicting. I want output as dates with no conflicts not listed in the output. I want to identify each "group" and that is why I added [group_no]. How can I "group" like this in SQL Server?

id name from_date to_date group_no ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 a1 1/1/2013 01/2/2013 1 2 a2 1/1/2013 01/2/2013 1 3 a3 5/1/2013 10/1/2013 2 4 a4 6/1/2013 08/1/2013 2 5 25 7/1/2013 07/1/2013 2

提前致谢, Amrritha

Thanks in advance, Amrritha

推荐答案

嗨 i用于迭代事件添加添加冲突事件与临时table.fetched冲突事件使用(fromdate和todate之间的@datefrom)和(fromdate和todate之间的@dateto) Hi i used while to iterate events add added conflicting events to temporary table.fetched conflicting events using ( @datefrom between fromdate and todate) and (@dateto between fromdate and todate)

更多推荐

如何从我的表中分组冲突事件

本文发布于:2023-11-22 01:09:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615382.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:冲突   事件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!