create table #(id int,type varchar(10),date datetime default getdate())
insert into # select 1,'开门','2008-1-1'
union all select 3,'开门','2008-1-2'
union all select 4,'开门','2008-1-3'
union all select 5,'关门','2008-1-4'
union all select 7,'开门','2008-1-5'
union all select 8,'开门','2008-1-7'
union all select 9,'关门','2008-1-11'
union all select 10,'关门','2008-1-12'
union all select 11,'开门','2008-1-13'
id type date
----------- ---------- ------------------------------------------------------ 1
1 开门 2008-01-01 00:00:00.000
5 关门 2008-01-04 00:00:00.000
7 开门 2008-01-05 00:00:00.000
10 关门 2008-01-12 00:00:00.000
(所影响的行数为 4 行)
id type date
----------- ---------- ------------------------------------------------------ 2
4 开门 2008-01-03 00:00:00.000
5 关门 2008-01-04 00:00:00.000
8 开门 2008-01-07 00:00:00.000
9 关门 2008-01-11 00:00:00.000
(所影响的行数为 4 行)