我有一个带有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)
更多推荐
如何从我的表中分组冲突事件
发布评论