select * from T a where (select count(1) from T where abs(ID-a.ID)=1 and [Date] is null)>1
--用lead select * from (select *, case when Date is null then 1 else 0 end as col1, case when lead(Date)over(order by ID)is null then 1 else 0 end col2 from T)TT where Col1=COl2 and Col1=1
select * from T a where (select count(1) from T where abs(ID-a.ID)=1 and [Date] is null)>1
select
*
from
(select
*,
case when Date is null then 1 else 0 end as col1,
case when lead(Date)over(order by ID)is null then 1 else 0 end col2
from
T)TT
where
Col1=COl2 and Col1=1
FYI:http://topic.csdn.net/u/20071019/01/e79e1215-f2d8-4179-a310-606ad5103649.html